Documentation ¶
Index ¶
- Constants
- Variables
- func Option(o map[string]interface{}) map[int]interface{}
- type HttpClient
- func (this *HttpClient) Begin() *HttpClient
- func (this *HttpClient) Do(method string, url string, headers map[string]string, body io.Reader) (*Response, error)
- func (this *HttpClient) Get(url string, params map[string]string) (*Response, error)
- func (this *HttpClient) Post(url string, params map[string]string) (*Response, error)
- func (this *HttpClient) PostMultipart(url string, params map[string]string) (*Response, error)
- func (this *HttpClient) WithCookie(cookie *http.Cookie) *HttpClient
- func (this *HttpClient) WithHeader(k string, v string) *HttpClient
- func (this *HttpClient) WithHeaders(m map[string]string) *HttpClient
- func (this *HttpClient) WithOption(k int, v interface{}) *HttpClient
- func (this *HttpClient) WithOptions(m map[int]interface{}) *HttpClient
- type Response
Constants ¶
View Source
const ( VERSION = "0.3.1" USERAGENT = "go-httpclient v" + VERSION PROXY_HTTP = 0 PROXY_SOCKS4 = 4 PROXY_SOCKS5 = 5 PROXY_SOCKS4A = 6 // CURL like OPT OPT_AUTOREFERER = 58 OPT_FOLLOWLOCATION = 52 OPT_CONNECTTIMEOUT = 78 OPT_CONNECTTIMEOUT_MS = 156 OPT_MAXREDIRS = 68 OPT_PROXYTYPE = 101 OPT_TIMEOUT = 13 OPT_TIMEOUT_MS = 155 OPT_COOKIEJAR = 10082 OPT_INTERFACE = 10062 OPT_PROXY = 10004 OPT_REFERER = 10016 OPT_USERAGENT = 10018 // Other OPT OPT_REDIRECT_POLICY = 100000 OPT_PROXY_FUNC = 100001 )
Variables ¶
View Source
var CONST = map[string]int{
"OPT_AUTOREFERER": 58,
"OPT_FOLLOWLOCATION": 52,
"OPT_CONNECTTIMEOUT": 78,
"OPT_CONNECTTIMEOUT_MS": 156,
"OPT_MAXREDIRS": 68,
"OPT_PROXYTYPE": 101,
"OPT_TIMEOUT": 13,
"OPT_TIMEOUT_MS": 155,
"OPT_COOKIEJAR": 10082,
"OPT_INTERFACE": 10062,
"OPT_PROXY": 10004,
"OPT_REFERER": 10016,
"OPT_USERAGENT": 10018,
"OPT_REDIRECT_POLICY": 100000,
"OPT_PROXY_FUNC": 100001,
}
Functions ¶
Types ¶
type HttpClient ¶
type HttpClient struct { Options map[int]interface{} Headers map[string]string // contains filtered or unexported fields }
func NewHttpClient ¶
func NewHttpClient(options map[int]interface{}) *HttpClient
func (*HttpClient) Begin ¶ added in v0.3.0
func (this *HttpClient) Begin() *HttpClient
func (*HttpClient) Post ¶
The POST request
With multipart set to true, the request will be encoded as "multipart/form-data". If any of the params key starts with "@", it is considered as a form file (similar to CURL but different).
func (*HttpClient) PostMultipart ¶ added in v0.2.1
Post with the request encoded as "multipart/form-data".
func (*HttpClient) WithCookie ¶ added in v0.3.0
func (this *HttpClient) WithCookie(cookie *http.Cookie) *HttpClient
func (*HttpClient) WithHeader ¶ added in v0.2.1
func (this *HttpClient) WithHeader(k string, v string) *HttpClient
func (*HttpClient) WithHeaders ¶ added in v0.2.1
func (this *HttpClient) WithHeaders(m map[string]string) *HttpClient
func (*HttpClient) WithOption ¶ added in v0.2.1
func (this *HttpClient) WithOption(k int, v interface{}) *HttpClient
change the oneTimeOptions
func (*HttpClient) WithOptions ¶ added in v0.2.1
func (this *HttpClient) WithOptions(m map[int]interface{}) *HttpClient
Click to show internal directories.
Click to hide internal directories.