Documentation ¶
Index ¶
- Variables
- func HTTPGet(urlStr string) (body []byte, err error)
- type HTTPClient
- func (h *HTTPClient) ClearCookiejar()
- func (h *HTTPClient) Fetch(method string, urlStr string, post interface{}, header map[string]string) (body []byte, err error)
- func (h *HTTPClient) SetCookiejar(c *cookiejar.Jar)
- func (h *HTTPClient) SetGzip(b bool)
- func (h *HTTPClient) SetHTTPSecure(b bool)
- func (h *HTTPClient) SetKeepAlive(b bool)
- func (h *HTTPClient) SetResponseHeaderTimeout(t time.Duration)
- func (h *HTTPClient) SetTimeout(t time.Duration)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // UserAgent 浏览器标识 UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" // DefaultClient 默认 http 客户端 DefaultClient = NewHTTPClient() )
Functions ¶
Types ¶
type HTTPClient ¶
HTTPClient http client
func (*HTTPClient) Fetch ¶
func (h *HTTPClient) Fetch(method string, urlStr string, post interface{}, header map[string]string) (body []byte, err error)
Fetch 实现 http/https 访问 和 GET/POST 请求, 根据给定的 method (GET, POST, HEAD, PUT 等等), urlStr (网址), post (post 数据), header (header 请求头数据), 进行网站访问。 返回值分别为 网站主体, 错误
func (*HTTPClient) SetCookiejar ¶
func (h *HTTPClient) SetCookiejar(c *cookiejar.Jar)
SetCookiejar 设置 cookie
func (*HTTPClient) SetHTTPSecure ¶
func (h *HTTPClient) SetHTTPSecure(b bool)
SetHTTPSecure 是否启用 https 安全检查
func (*HTTPClient) SetKeepAlive ¶
func (h *HTTPClient) SetKeepAlive(b bool)
SetKeepAlive 设置 Keep-Alive
func (*HTTPClient) SetResponseHeaderTimeout ¶
func (h *HTTPClient) SetResponseHeaderTimeout(t time.Duration)
SetResponseHeaderTimeout 设置目标服务器响应超时时间
func (*HTTPClient) SetTimeout ¶
func (h *HTTPClient) SetTimeout(t time.Duration)
SetTimeout 设置 http 请求超时时间 默认30s
Click to show internal directories.
Click to hide internal directories.