Documentation ¶
Index ¶
- Variables
- func Fetch(method string, urlStr string, post interface{}, header map[string]string) ([]byte, error)
- func HTTPGet(urlStr string) ([]byte, error)
- func Headers(url string) (http.Header, error)
- func Req(method string, urlStr string, post interface{}, header map[string]string) (*http.Response, error)
- func Size(url string) (int, error)
- type HTTPClient
- func (h *HTTPClient) Fetch(method string, urlStr string, post interface{}, header map[string]string) ([]byte, error)
- func (h *HTTPClient) Req(method string, urlStr string, post interface{}, header map[string]string) (*http.Response, error)
- func (h *HTTPClient) ResetCookieJar()
- func (h *HTTPClient) SetCookiejar(jar http.CookieJar)
- func (h *HTTPClient) SetTimeout(t time.Duration)
- func (h *HTTPClient) SetUserAgent(ua string)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // UserAgent 浏览器标识 UserAgent = "" /* 139-byte string literal not displayed */ //DefaultClient 默认 http 客户端 DefaultClient = NewHTTPClient() )
Functions ¶
func Fetch ¶
func Fetch(method string, urlStr string, post interface{}, header map[string]string) ([]byte, error)
Fetch 参见 *HTTPClient.Fetch, 使用默认 http 客户端
Types ¶
type HTTPClient ¶
HTTPClient client
func (*HTTPClient) Fetch ¶
func (h *HTTPClient) Fetch(method string, urlStr string, post interface{}, header map[string]string) ([]byte, error)
Fetch 实现 http/https 访问, 根据给定的 method (GET, POST, HEAD, PUT 等等), urlStr (网址), post (post 数据), header (header 请求头数据), 进行网站访问。 返回值分别为 []byte, 错误信息
func (*HTTPClient) Req ¶
func (h *HTTPClient) Req(method string, urlStr string, post interface{}, header map[string]string) (*http.Response, error)
Req 实现 http/https 访问, 根据给定的 method (GET, POST, HEAD, PUT 等等), urlStr (网址), post (post 数据), header (header 请求头数据), 进行网站访问。 返回值分别为 *http.Response, 错误信息
func (*HTTPClient) ResetCookieJar ¶
func (h *HTTPClient) ResetCookieJar()
ResetCookieJar 重置cookie jar
func (*HTTPClient) SetCookiejar ¶
func (h *HTTPClient) SetCookiejar(jar http.CookieJar)
SetCookiejar 设置 Cookie
func (*HTTPClient) SetUserAgent ¶
func (h *HTTPClient) SetUserAgent(ua string)
SetUserAgent 设置 UserAgent 浏览器标识
Click to show internal directories.
Click to hide internal directories.