Documentation ¶
Overview ¶
Package zhttp provides http client related operations
Index ¶
- Constants
- Variables
- func BodyJSON(v interface{}) *bodyJson
- func BodyXML(v interface{}) *bodyXml
- func Client() *http.Client
- func EnableCookie(enable bool)
- func EnableInsecureTLS(enable bool)
- func File(patterns ...string) interface{}
- func Flags() int
- func RemoveProxy() error
- func SetClient(client *http.Client)
- func SetFlags(flags int)
- func SetJSONEscapeHTML(escape bool)
- func SetJSONIndent(prefix, indent string)
- func SetProxy(proxy func(*http.Request) (*url.URL, error)) error
- func SetProxyUrl(rawurl string) error
- func SetTimeout(d time.Duration)
- func SetXMLIndent(prefix, indent string)
- type DownloadProgress
- type Engine
- func (r *Engine) CheckRedirect(fn ...func(req *http.Request, via []*http.Request) error)
- func (r *Engine) Client() *http.Client
- func (r *Engine) Delete(url string, v ...interface{}) (*Res, error)
- func (r *Engine) Do(method, rawurl string, vs ...interface{}) (resp *Res, err error)
- func (r *Engine) EnableCookie(enable bool)
- func (r *Engine) EnableInsecureTLS(enable bool)
- func (r *Engine) Get(url string, v ...interface{}) (*Res, error)
- func (r *Engine) GetFlags() int
- func (r *Engine) Head(url string, v ...interface{}) (*Res, error)
- func (r *Engine) Options(url string, v ...interface{}) (*Res, error)
- func (r *Engine) Patch(url string, v ...interface{}) (*Res, error)
- func (r *Engine) Post(url string, v ...interface{}) (*Res, error)
- func (r *Engine) Put(url string, v ...interface{}) (*Res, error)
- func (r *Engine) RemoveProxy() error
- func (r *Engine) SetClient(client *http.Client)
- func (r *Engine) SetFlags(flags int)
- func (r *Engine) SetJSONEscapeHTML(escape bool)
- func (r *Engine) SetJSONIndent(prefix, indent string)
- func (r *Engine) SetProxy(proxy func(*http.Request) (*url.URL, error)) error
- func (r *Engine) SetProxyUrl(rawurl string) error
- func (r *Engine) SetSsl(certPath, keyPath, CAPath string) (*tls.Config, error)
- func (r *Engine) SetTimeout(d time.Duration)
- func (r *Engine) SetXMLIndent(prefix, indent string)
- type FileUpload
- type Header
- type Host
- type Param
- type QueryParam
- type Res
- func Delete(url string, v ...interface{}) (*Res, error)
- func Do(method, url string, v ...interface{}) (*Res, error)
- func Get(url string, v ...interface{}) (*Res, error)
- func Head(url string, v ...interface{}) (*Res, error)
- func Options(url string, v ...interface{}) (*Res, error)
- func Patch(url string, v ...interface{}) (*Res, error)
- func Post(url string, v ...interface{}) (*Res, error)
- func Put(url string, v ...interface{}) (*Res, error)
- func (r *Res) Body() (body io.ReadCloser)
- func (r *Res) Bytes() []byte
- func (r *Res) Cost() time.Duration
- func (r *Res) Dump() string
- func (r *Res) GetCookie() map[string]*http.Cookie
- func (r *Res) Request() *http.Request
- func (r *Res) Response() *http.Response
- func (r *Res) String() string
- func (r *Res) ToBytes() ([]byte, error)
- func (r *Res) ToFile(name string) error
- func (r *Res) ToJSON(v interface{}) error
- func (r *Res) ToString() (string, error)
- func (r *Res) ToXML(v interface{}) error
- func (m Res) Upload(req *http.Request)
- type UploadProgress
Constants ¶
View Source
const ( BitReqHead = 1 << iota BitReqBody BitRespHead BitRespBody BitTime BitStdFlags = BitReqHead | BitReqBody | BitRespHead | BitRespBody )
Variables ¶
View Source
var ( ErrNoTransport = errors.New("no transport") ErrUrlNotSpecified = errors.New("url not specified") ErrTransEmpty = errors.New("trans is empty") ErrNoMatched = errors.New("no file have been matched") )
View Source
var (
Debug = false
)
Functions ¶
func BodyJSON ¶
func BodyJSON(v interface{}) *bodyJson
BodyJSON make the object be encoded in json format and set it to the request body
func BodyXML ¶
func BodyXML(v interface{}) *bodyXml
BodyXML make the object be encoded in xml format and set it to the request body
func EnableCookie ¶
func EnableCookie(enable bool)
func EnableInsecureTLS ¶
func EnableInsecureTLS(enable bool)
func RemoveProxy ¶ added in v0.1.26
func RemoveProxy() error
func SetJSONEscapeHTML ¶
func SetJSONEscapeHTML(escape bool)
func SetJSONIndent ¶
func SetJSONIndent(prefix, indent string)
func SetProxyUrl ¶
func SetTimeout ¶
func SetXMLIndent ¶
func SetXMLIndent(prefix, indent string)
Types ¶
type DownloadProgress ¶
type DownloadProgress func(current, total int64)
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) CheckRedirect ¶ added in v0.0.19
func (*Engine) EnableCookie ¶
func (*Engine) EnableInsecureTLS ¶
func (*Engine) RemoveProxy ¶ added in v0.1.26
func (*Engine) SetJSONEscapeHTML ¶
func (*Engine) SetJSONIndent ¶
func (*Engine) SetProxyUrl ¶
func (*Engine) SetTimeout ¶
func (*Engine) SetXMLIndent ¶
type FileUpload ¶
type FileUpload struct { FileName string FieldName string File io.ReadCloser }
type QueryParam ¶
type QueryParam map[string]interface{}
type Res ¶
type Res struct {
// contains filtered or unexported fields
}
func (*Res) Body ¶
func (r *Res) Body() (body io.ReadCloser)
type UploadProgress ¶
type UploadProgress func(current, total int64)
Click to show internal directories.
Click to hide internal directories.