httpUtils

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpUtil

type HttpUtil struct {
	PoolSize int

	CookieManager *SessionCookieManager
	Redirect      bool
	// contains filtered or unexported fields
}

func New

func New(timeout, poolSize int, proxy string) *HttpUtil

func NewDefault

func NewDefault() *HttpUtil

func (*HttpUtil) Close

func (c *HttpUtil) Close()

func (*HttpUtil) Get

func (c *HttpUtil) Get(url string) (string, error)

func (*HttpUtil) HttpBaseRequest

func (c *HttpUtil) HttpBaseRequest(req *http.Request) ([]byte, *http.Response, error)

func (*HttpUtil) HttpRequest

func (c *HttpUtil) HttpRequest(method, url, queryString, contentType string) (string, error)

func (*HttpUtil) NewConnect

func (c *HttpUtil) NewConnect(timeout int, proxy string) *http.Client

func (*HttpUtil) Post

func (c *HttpUtil) Post(url, queryString string) (string, error)

func (*HttpUtil) PostForm

func (c *HttpUtil) PostForm(url, queryString, form string) (string, error)

func (*HttpUtil) PostJson

func (c *HttpUtil) PostJson(url, queryString string) (string, error)

func (*HttpUtil) SetProxy

func (c *HttpUtil) SetProxy(proxy string)

type SessionCookieManager

type SessionCookieManager struct {
	Key   []string // cookie 的key
	Value []string // cookie 的vlaue
}

func NewCookieManager

func NewCookieManager() *SessionCookieManager

func (*SessionCookieManager) ClearCookies added in v0.0.11

func (scm *SessionCookieManager) ClearCookies()

func (*SessionCookieManager) ParseCookieString

func (cookieManager *SessionCookieManager) ParseCookieString(cookieString string)

func (*SessionCookieManager) String

func (scm *SessionCookieManager) String() string

cookie 键值 slice to string

func (*SessionCookieManager) Update

func (scm *SessionCookieManager) Update(res *http.Response)

func (*SessionCookieManager) UpdateFromResponseWithCallback added in v0.0.11

func (scm *SessionCookieManager) UpdateFromResponseWithCallback(cookies []*http.Cookie, callback func(key, value string))

func (*SessionCookieManager) UpdateWithCallback added in v0.0.11

func (scm *SessionCookieManager) UpdateWithCallback(res *http.Response, callback func(key, value string))

根据响应里的cookie 更新cookie 从而达到维持session的目的

func (*SessionCookieManager) Upsert

func (scm *SessionCookieManager) Upsert(key, value string)

有则更新 无则插入

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL