Documentation ¶
Index ¶
- type CURL
- func (c *CURL) CreateRequest() (request *http.Request, err error)
- func (c *CURL) Do(ctx context.Context) (resp *Response, err error)
- func (c *CURL) HandleResponse(resp *http.Response) (response *Response, err error)
- func (c *CURL) SetContext(ctx context.Context)
- func (c *CURL) SetCookie(cookie string)
- func (c *CURL) SetDefaultHeaders()
- func (c *CURL) SetHeader(key, value string)
- func (c *CURL) SetMethod(method string) error
- func (c *CURL) SetOption(key string, value bool)
- func (c *CURL) SetPostBytes(p []byte)
- func (c *CURL) SetPostFieldReaders(p map[string]io.Reader)
- func (c *CURL) SetPostFields(p neturl.Values)
- func (c *CURL) SetPostFiles(p neturl.Values)
- func (c *CURL) SetPostReader(p io.Reader)
- func (c *CURL) SetPostString(p string)
- func (c *CURL) SetTimeout(sec time.Duration)
- func (c *CURL) SetUrl(url string)
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CURL ¶
type CURL struct { // -H 添加http请求标头 URL string Method string Cookie string Referer string Headers map[string]string // header Options map[string]bool // --data PostBytes []byte // binary data PostString string // string data PostFields neturl.Values // k-v format PostReader io.Reader // from reader PostFieldReaders map[string]io.Reader // from map reader PostFiles neturl.Values // key 文件名;value 文件路径 Timeout time.Duration // ctx 超时时间 // contains filtered or unexported fields }
refer: http://www.ruanyifeng.com/blog/2011/09/curl.html http://www.ruanyifeng.com/blog/2019/09/curl-reference.html
func (*CURL) CreateRequest ¶
return http's request and set headers.
func (*CURL) Do ¶
start Do http request
if ctx is nil then set ctx equal context.Background() and meantime set timeout 5 second.
func (*CURL) HandleResponse ¶
func (*CURL) SetContext ¶
func (*CURL) SetDefaultHeaders ¶
func (c *CURL) SetDefaultHeaders()
func (*CURL) SetPostFieldReaders ¶
field's io.Reader for data content
func (*CURL) SetPostFields ¶
map[string][]string for data content
func (*CURL) SetTimeout ¶
Click to show internal directories.
Click to hide internal directories.