Documentation ¶
Index ¶
- Constants
- func HTTPGet(url string) ([]byte, error)
- func HTTPost(url string, input []byte) ([]byte, error)
- type BasicAuth
- type Client
- func (c *Client) ClearCookies()
- func (c *Client) PostForm(url string, form map[string]io.Reader) (*HTTPResponse, error)
- func (c *Client) PostForm2(url string, values map[string]string) (*HTTPResponse, error)
- func (c *Client) Request(action, url string, input []byte, retry int) (*HTTPResponse, error)
- func (c *Client) SetCookie(cookie *http.Cookie)
- func (c *Client) SetDebug(d bool)
- func (c *Client) SetHTTPTimeout(timeout time.Duration)
- func (c *Client) SetTransport(transport http.RoundTripper)
- type HTTPResponse
Constants ¶
View Source
const ( POST = "POST" GET = "GET" PUT = "PUT" PATCH = "PATCH" DELETE = "DELETE" HEAD = "HEAD" OPTIONS = "OPTIONS" TRACE = "TRACE" CONNECT = "CONNECT" )
View Source
const ( XwwwFormUrlencoded = "application/x-www-form-urlencoded" FormData = "application/form-data" )
View Source
const (
ContentType = "Content-Type"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { HttpClient *http.Client Header map[string]string Version string MaxIdleConns int MaxConnsPerHost int Debug bool Auth BasicAuth Cookies []*http.Cookie }
Client http 客户端
var HTTP *Client
HTTP Client
func (*Client) ClearCookies ¶ added in v1.0.4
func (c *Client) ClearCookies()
ClearCookies 清除cookies
func (*Client) PostForm ¶
PostForm 发起PostForm请求 from-data方式
example
file, _ := os.Open("file.png") //读取文件 defer file.Close()
form := map[string]io.Reader{} //定义form form["source"] = strings.NewReader("post") //字符串 form["file"] = file //文件类型
func (*Client) Request ¶
Request 发起HTTP请求
* action:POST\GET\PUT\PATCH\DELETE\HEAD\OPTIONS\TRACE\CONNECT * url:请求地址 * input:请求参数 * retry:重试次数,默认0(不重试)
func (*Client) SetHTTPTimeout ¶
SetHTTPTimeout 设置http 超时时间
func (*Client) SetTransport ¶
func (c *Client) SetTransport(transport http.RoundTripper)
SetTransport 设置Transport
Click to show internal directories.
Click to hide internal directories.