Documentation ¶
Index ¶
- Constants
- Variables
- func NewClient() *http.Client
- func NewTransport() *http.Transport
- func ProxyFromEnvironment(req *http.Request) (*url.URL, error)
- type Option
- func WithBasicAuth(username, password string) Option
- func WithBearerTokenAuth(token string) Option
- func WithClient(client *http.Client) Option
- func WithDefaultClient() Option
- func WithDefaultTransport() Option
- func WithHeader(headers ...map[string]string) Option
- func WithProxyEnv(proxy Proxy) Option
- func WithProxyFunc(f func(*http.Request) (*url.URL, error)) Option
- func WithProxyUrl(proxy *url.URL) Option
- func WithSkipTLS() Option
- func WithTimeout(t time.Duration) Option
- func WithTransport(tr http.RoundTripper) Option
- func WithUnsetProxy() Option
- type Proxy
- type Request
- func (r *Request) CloseIdleConnections()
- func (r Request) Content() []byte
- func (r Request) ContentToString() string
- func (r *Request) Delete(originUrl string, data map[string]interface{}) error
- func (r *Request) Download(filePath, originUrl string, rate int64) error
- func (r *Request) DownloadToWriter(originUrl string, w io.Writer) error
- func (r *Request) Get(originUrl string, params map[string]string) error
- func (r *Request) ParseUrl(originUrl string) error
- func (r *Request) Post(originUrl string, data map[string]interface{}) error
- func (r *Request) PostForm(originUrl string, data map[string]string) error
- func (r *Request) Put(originUrl string, data map[string]interface{}) error
- func (r Request) Request() *http.Request
- func (r Request) Response() *http.Response
- func (r *Request) SetBasicAuth(username, password string)
- func (r *Request) SetBearerTokenAuth(token string)
- func (r *Request) SetClient(client *http.Client)
- func (r *Request) SetHeader(header map[string]string)
- func (r *Request) SetProxyEnv(proxy Proxy)
- func (r *Request) SetProxyFunc(f func(*http.Request) (*url.URL, error))
- func (r *Request) SetProxyUrl(proxy *url.URL)
- func (r *Request) SetSkipTLS()
- func (r *Request) SetTimeout(t time.Duration)
- func (r *Request) SetTransport(rt http.RoundTripper)
- func (r Request) Status() (int, string)
- func (r *Request) UnsetProxy()
- func (r *Request) Upload(originUrl string, data map[string]string, rate int64, filePaths ...string) error
Constants ¶
View Source
const ( ProxyHttp = "http" ProxySocks = "socks5" )
View Source
const ( ContentTypeJson = "application/json;charset=utf-8" ContentTypeForm = "application/x-www-form-urlencoded" )
Variables ¶
View Source
var ( DefaultTransport = NewTransport() DefaultClient = NewClient() )
Functions ¶
func NewTransport ¶ added in v1.2.12
NewTransport is clone of http.DefaultTransport
Types ¶
type Option ¶ added in v1.1.5
type Option func(*Request)
func WithBasicAuth ¶ added in v1.1.5
func WithBearerTokenAuth ¶ added in v1.1.5
func WithClient ¶ added in v1.2.10
func WithDefaultClient ¶ added in v1.2.10
func WithDefaultClient() Option
func WithDefaultTransport ¶ added in v1.2.10
func WithDefaultTransport() Option
func WithHeader ¶ added in v1.1.5
func WithProxyEnv ¶ added in v1.2.12
func WithProxyFunc ¶ added in v1.2.7
func WithProxyUrl ¶ added in v1.2.12
func WithSkipTLS ¶ added in v1.2.12
func WithSkipTLS() Option
func WithTimeout ¶ added in v1.1.5
func WithTransport ¶ added in v1.2.4
func WithTransport(tr http.RoundTripper) Option
func WithUnsetProxy ¶ added in v1.2.6
func WithUnsetProxy() Option
type Proxy ¶ added in v1.2.8
func NewHttpProxy ¶ added in v1.2.8
func NewHttpProxyWithAuth ¶ added in v1.2.8
func NewSocksProxy ¶ added in v1.2.8
func NewSocksProxyWithAuth ¶ added in v1.2.8
type Request ¶ added in v1.0.2
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶ added in v1.0.2
func NewSession ¶
func (*Request) CloseIdleConnections ¶ added in v1.2.14
func (r *Request) CloseIdleConnections()
func (Request) ContentToString ¶ added in v1.1.0
func (*Request) Download ¶ added in v1.0.7
Download rate is download speed per second, e.g. 1024 ==> 1KiB/s, 1024*1024 ==> 1MiB/s, if rate <= 0 it means no limit
func (*Request) DownloadToWriter ¶ added in v1.2.13
func (*Request) SetBasicAuth ¶ added in v1.0.3
func (*Request) SetBearerTokenAuth ¶ added in v1.0.3
func (*Request) SetProxyEnv ¶ added in v1.2.12
func (*Request) SetProxyFunc ¶ added in v1.2.12
func (*Request) SetProxyUrl ¶ added in v1.2.12
func (*Request) SetSkipTLS ¶ added in v1.2.12
func (r *Request) SetSkipTLS()
func (*Request) SetTimeout ¶ added in v1.0.3
func (*Request) SetTransport ¶ added in v1.2.3
func (r *Request) SetTransport(rt http.RoundTripper)
func (*Request) UnsetProxy ¶ added in v1.2.6
func (r *Request) UnsetProxy()
Click to show internal directories.
Click to hide internal directories.