Documentation
¶
Index ¶
- func SetDefaultSetting(setting HTTPSettings)
- func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
- type Context
- func (b *Context) Body(data interface{}) *Context
- func (b *Context) Bytes() ([]byte, error)
- func (b *Context) Debug(isdebug bool) *Context
- func (b *Context) DoRequest() (resp *http.Response, err error)
- func (b *Context) DumpBody(isdump bool) *Context
- func (b *Context) DumpRequest() []byte
- func (b *Context) GetRequest() *http.Request
- func (b *Context) Header(key, value string) *Context
- func (b *Context) JSONBody(obj interface{}) (*Context, error)
- func (b *Context) Param(key, value string) *Context
- func (b *Context) PostFile(formname, filename string) *Context
- func (b *Context) Response() (*http.Response, error)
- func (b *Context) Retries(times int) *Context
- func (b *Context) SetBasicAuth(username, password string) *Context
- func (b *Context) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *Context
- func (b *Context) SetCookie(cookie *http.Cookie) *Context
- func (b *Context) SetEnableCookie(enable bool) *Context
- func (b *Context) SetHost(host string) *Context
- func (b *Context) SetProtocolVersion(vers string) *Context
- func (b *Context) SetProxy(proxy func(*http.Request) (*url.URL, error)) *Context
- func (b *Context) SetTLSClientConfig(config *tls.Config) *Context
- func (b *Context) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Context
- func (b *Context) SetTransport(transport http.RoundTripper) *Context
- func (b *Context) SetUserAgent(useragent string) *Context
- func (b *Context) Setting(setting HTTPSettings) *Context
- func (b *Context) String() (string, error)
- func (b *Context) ToFile(filename string) error
- func (b *Context) ToJSON(v interface{}) error
- func (b *Context) ToXML(v interface{}) error
- type HTTPSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultSetting ¶
func SetDefaultSetting(setting HTTPSettings)
SetDefaultSetting Overwrite default settings
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
一个请求上下文
func NewRequest ¶
func (*Context) DumpRequest ¶
DumpRequest return the DumpRequest
func (*Context) Param ¶
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*Context) Retries ¶
Retries sets Retries times. default is 0 means no retried. -1 means retried forever. others means retried times.
func (*Context) SetBasicAuth ¶
request的代理方法
func (*Context) SetCheckRedirect ¶
func (b *Context) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *Context
SetCheckRedirect specifies the policy for handling redirects.
If CheckRedirect is nil, the Client uses its default policy, which is to stop after 10 consecutive requests.
func (*Context) SetEnableCookie ¶
request的代理方法
func (*Context) SetProtocolVersion ¶
SetProtocolVersion Set the protocol version for incoming requests. Client requests always use HTTP/1.1.
func (*Context) SetProxy ¶
SetProxy set the web api example:
func(req *web.Request) (*url.URL, error) { u, _ := url.ParseRequestURI("http://127.0.0.1:8118") return u, nil }
func (*Context) SetTLSClientConfig ¶
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*Context) SetTimeout ¶
SetTimeout sets connect time out and read-write time out for BeegoRequest.
func (*Context) SetTransport ¶
func (b *Context) SetTransport(transport http.RoundTripper) *Context
SetTransport set the setting transport
func (*Context) SetUserAgent ¶
SetUserAgent sets User-Agent header field
func (*Context) ToFile ¶
ToFile saves the body data in response to one file. it calls Response inner.
type HTTPSettings ¶
type HTTPSettings struct { ShowDebug bool UserAgent string ConnectTimeout time.Duration ReadWriteTimeout time.Duration TLSClientConfig *tls.Config Proxy func(*http.Request) (*url.URL, error) Transport http.RoundTripper CheckRedirect func(req *http.Request, via []*http.Request) error EnableCookie bool Gzip bool DumpBody bool Retries int // if set to -1 means will retry forever }
web.Client setting