Documentation ¶
Index ¶
- Constants
- func CreateTransport(timeout *Timeout, keepAlive bool) (ret *http.Transport)
- func SetProxy(p *Proxy)
- type Client
- func (p *Client) Get(url string) (*http.Response, error)
- func (p *Client) GetBytes(url string) ([]byte, error)
- func (p *Client) GetJSON(url string, v interface{}) error
- func (p *Client) GetXML(url string, v interface{}) error
- func (p *Client) Post(url string, body io.Reader) (*http.Response, error)
- func (p *Client) PostBytes(url string, body []byte) ([]byte, error)
- func (p *Client) PostForm(url string, data url.Values) (*http.Response, error)
- func (p *Client) PostFormBytes(url string, data url.Values) ([]byte, error)
- func (p *Client) PostFormJSON(url string, data url.Values, v interface{}) error
- func (p *Client) PostFormXML(url string, data url.Values, v interface{}) error
- func (p *Client) PostJSON(url string, body interface{}, v interface{}) error
- func (p *Client) PostNone(url string, body io.Reader) error
- func (p *Client) PostXML(url string, body interface{}, v interface{}) error
- func (p *Client) Put(url string, body io.Reader) (*http.Response, error)
- func (p *Client) PutBytes(url string, body []byte) ([]byte, error)
- func (p *Client) PutForm(url string, data url.Values) (*http.Response, error)
- func (p *Client) PutFormBytes(url string, data url.Values) ([]byte, error)
- func (p *Client) PutFormJSON(url string, data url.Values, v interface{}) error
- func (p *Client) PutFormXML(url string, data url.Values, v interface{}) error
- func (p *Client) PutJSON(url string, body interface{}, v interface{}) error
- func (p *Client) PutNone(url string, body io.Reader) error
- func (p *Client) PutXML(url string, body interface{}, v interface{}) error
- func (p *Client) Request(method, url string, body io.Reader) (*http.Response, error)
- func (p *Client) RequestBytes(method, url string, body []byte) ([]byte, error)
- func (p *Client) RequestForm(method, url string, data url.Values) (*http.Response, error)
- func (p *Client) RequestFormBytes(method, url string, data url.Values) ([]byte, error)
- func (p *Client) RequestFormJSON(method, url string, data url.Values, v interface{}) error
- func (p *Client) RequestFormXML(method, url string, data url.Values, v interface{}) error
- func (p *Client) RequestJSON(method, url string, body interface{}, v interface{}) error
- func (p *Client) RequestNone(method, url string, body io.Reader) error
- func (p *Client) RequestXML(method, url string, body interface{}, v interface{}) error
- type Proxy
- type Timeout
Constants ¶
View Source
const ( HTTPHeaderAccept = "Accept" HTTPHeaderAcceptEncoding = "Accept-Encoding" HTTPHeaderAuthorization = "Authorization" HTTPHeaderCacheControl = "Cache-Control" HTTPHeaderContentDisposition = "Content-Disposition" HTTPHeaderContentEncoding = "Content-Encoding" HTTPHeaderContentLength = "Content-Length" HTTPHeaderContentMD5 = "Content-MD5" HTTPHeaderContentType = "Content-Type" HTTPHeaderContentLanguage = "Content-Language" HTTPHeaderDate = "Date" HTTPHeaderEtag = "ETag" HTTPHeaderExpires = "Expires" HTTPHeaderHost = "Host" HTTPHeaderLastModified = "Last-Modified" HTTPHeaderRange = "Range" HTTPHeaderLocation = "Location" HTTPHeaderOrigin = "Origin" HTTPHeaderServer = "Server" HTTPHeaderUserAgent = "User-Agent" HTTPHeaderIfModifiedSince = "If-Modified-Since" HTTPHeaderIfUnmodifiedSince = "If-Unmodified-Since" HTTPHeaderIfMatch = "If-Match" HTTPHeaderIfNoneMatch = "If-None-Match" HTTPHeaderProxyAuthorization = "Proxy-Authorization" )
Http Header name
View Source
const (
ContentTypeForm = "application/x-www-form-urlencoded"
)
Variables ¶
This section is empty.
Functions ¶
func CreateTransport ¶
CreateTransport 创建Transport, timeout可以为nil,使用proxySetting
Types ¶
type Client ¶
http客户端
func (*Client) PostFormBytes ¶
func (*Client) PostFormJSON ¶
func (*Client) PostFormXML ¶
func (*Client) PutFormBytes ¶
func (*Client) PutFormJSON ¶
func (*Client) PutFormXML ¶
func (*Client) RequestBytes ¶
func (*Client) RequestForm ¶
func (*Client) RequestFormBytes ¶
func (*Client) RequestFormJSON ¶
func (*Client) RequestFormXML ¶
func (*Client) RequestJSON ¶
func (*Client) RequestNone ¶
仅执行,不检查响应数据.
func (*Client) RequestXML ¶
type Proxy ¶
type Proxy struct { Host string //host name User string //user name for auth. default is "" which means that doesn't use. Password string //password for auth. }
Proxy setting
type Timeout ¶
type Timeout struct { Connect time.Duration //connection timeout Read time.Duration //read timeout Write time.Duration //write timeout Header time.Duration //timeout for waiting Response Header Idle time.Duration //timeout for idle }
Timeout timeout setting. Default is 0 which means that doesn't use and use golang default setting.
Click to show internal directories.
Click to hide internal directories.