Documentation
¶
Index ¶
- Variables
- type PrepareRequest
- func (pr *PrepareRequest) Hash() string
- func (pr *PrepareRequest) Prepare(method, url string, params *url.Params, headers *http.Header, ...) error
- func (pr *PrepareRequest) Prepare_auth(auth []string, rawurl string) error
- func (pr *PrepareRequest) Prepare_body(data *url.Values, files *url.Files, json map[string]interface{}, ...) error
- func (pr *PrepareRequest) Prepare_cookies(cookies *cookiejar.Jar)
- func (pr *PrepareRequest) Prepare_headers(headers *http.Header) error
- func (pr *PrepareRequest) Prepare_method(method string) error
- func (pr *PrepareRequest) Prepare_url(rawurl string, params *url.Params) error
- type Request
- type Response
- func (res *Response) Close() error
- func (res Response) IsPermanentRedirect() bool
- func (res Response) IsRedirect() bool
- func (res *Response) Json() (map[string]interface{}, error)
- func (res Response) Ok() bool
- func (res *Response) RaiseForStatus() error
- func (res *Response) SimpleJson() (*simplejson.Json, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var MethodNames = []string{http.MethodGet, http.MethodPost, http.MethodOptions, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodDelete, http.MethodConnect, http.MethodTrace}
HTTP的所有请求方法
View Source
var PermanentRedirectStatusCodes = []int{ http.StatusMovedPermanently, http.StatusPermanentRedirect, }
View Source
var RedirectStatusCodes = []int{ http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect, http.StatusPermanentRedirect, }
Functions ¶
This section is empty.
Types ¶
type PrepareRequest ¶
type PrepareRequest struct {
Method string
Url string
Headers *http.Header
Cookies *cookiejar.Jar
Body io.Reader
}
PrepareRequest结构体
func NewPrepareRequest ¶
func NewPrepareRequest() *PrepareRequest
func (*PrepareRequest) Hash ¶
func (pr *PrepareRequest) Hash() string
func (*PrepareRequest) Prepare ¶
func (pr *PrepareRequest) Prepare(method, url string, params *url.Params, headers *http.Header, cookies *cookiejar.Jar, data *url.Values, files *url.Files, json map[string]interface{}, body io.Reader, auth []string) error
预处理所有数据
func (*PrepareRequest) Prepare_auth ¶
func (pr *PrepareRequest) Prepare_auth(auth []string, rawurl string) error
预处理auth
func (*PrepareRequest) Prepare_body ¶
func (pr *PrepareRequest) Prepare_body(data *url.Values, files *url.Files, json map[string]interface{}, bodys io.Reader) error
预处理body
func (*PrepareRequest) Prepare_cookies ¶
func (pr *PrepareRequest) Prepare_cookies(cookies *cookiejar.Jar)
预处理cookie
func (*PrepareRequest) Prepare_headers ¶
func (pr *PrepareRequest) Prepare_headers(headers *http.Header) error
预处理headers
func (*PrepareRequest) Prepare_method ¶
func (pr *PrepareRequest) Prepare_method(method string) error
预处理method
func (*PrepareRequest) Prepare_url ¶
func (pr *PrepareRequest) Prepare_url(rawurl string, params *url.Params) error
预处理url
type Request ¶
type Request struct {
Method string
Url string
Params *url.Params
Headers *http.Header
Cookies *cookiejar.Jar
Data *url.Values
Files *url.Files
Body io.Reader
Json map[string]interface{}
Auth []string
}
func (*Request) Prepare ¶
func (req *Request) Prepare() *PrepareRequest
type Response ¶
type Response struct {
Url string
Headers http.Header
Cookies []*http.Cookie
Text string
Content []byte
Body io.ReadCloser
StatusCode int
History []*Response
Request *url.Request
}
Response结构体
func (*Response) SimpleJson ¶
func (res *Response) SimpleJson() (*simplejson.Json, error)
使用go-simplejson解析
Click to show internal directories.
Click to hide internal directories.