Documentation ¶
Index ¶
- Constants
- Variables
- func BuildQueryEncoded(source [][2]string, charset Charset) ([]byte, error)
- func CookieJar() http.CookieJar
- func DialContext(connTimeout, KeepAlive, rwTimeout time.Duration) func(ctx context.Context, network, address string) (net.Conn, error)
- func ReadCookies(lines []string, filter string) []*http.Cookie
- type Builder
- type Charset
- type CharsetEncoderFunc
- type Client
- type HttpClient
- type ProtoMajor
- type Proxy
- type Request
- func (r *Request) AddCookie(ck *http.Cookie) *Request
- func (r *Request) ClearCookie() *Request
- func (r *Request) Connect() *Request
- func (r *Request) Delete() *Request
- func (r *Request) Form(k string, v string) *Request
- func (r *Request) GB18030() *Request
- func (r *Request) Get() *Request
- func (r *Request) Head(k, v string) *Request
- func (r *Request) MethodHead() *Request
- func (r *Request) Options() *Request
- func (r *Request) OriginInHeader(origin string) *Request
- func (r *Request) Patch() *Request
- func (r *Request) Post() *Request
- func (r *Request) Query(k, v string) *Request
- func (r *Request) RefererInHeader(refer string) *Request
- func (r *Request) Send() (resp *Response)
- func (r *Request) SetBody(body io.Reader) *Request
- func (r *Request) SetClient(client Client) *Request
- func (r *Request) SetCookies(c []*http.Cookie) *Request
- func (r *Request) SetForms(forms [][2]string) *Request
- func (r *Request) SetJSON(data interface{}) *Request
- func (r *Request) SetMethod(method string) *Request
- func (r *Request) SetQuerys(querys [][2]string) *Request
- func (r *Request) SetRetry(retry int) *Request
- func (r *Request) SetStringCookies(cookie string) *Request
- func (r *Request) SetUrl(rawurl string) *Request
- func (r *Request) UTF8() *Request
- type RequestConfig
- type Response
- func (r *Response) Body() ([]byte, error)
- func (r *Response) DetectedEncode() (err error)
- func (r *Response) Document() (doc *goquery.Document, err error)
- func (r *Response) DocumentDetectedEncode() (doc *goquery.Document, err error)
- func (r *Response) Encode(name string) *Response
- func (r *Response) Error() error
- func (r *Response) JSON(data interface{}) error
- func (r *Response) String() (string, error)
- type StoreCookie
Constants ¶
View Source
const ( Referer = "Referer" UserAgent = "User-Agent" Origin = "Origin" ContentType = "Content-Type" )
Variables ¶
View Source
var ( Verbose = false DefaultHttpClient = &http.Client{ Transport: HTTP1.RoundTripper(), } DefaultDialContext = DialContext(30*time.Second, 30*time.Second, 0) )
View Source
var ContentTypeMatchCharset = regexp.MustCompile(`[cC]harset=([\w|\-]*)`)
View Source
var DefaultClient = &HttpClient{Client: DefaultHttpClient}
View Source
var RoundTripFactory = map[ProtoMajor]func() http.RoundTripper{ HTTP1: defaultHttpRoundTripperFunc, HTTP2: func() http.RoundTripper { tripper := defaultHttpRoundTripperFunc().(*http.Transport) _ = http2.ConfigureTransport(tripper) return tripper }, }
Functions ¶
func BuildQueryEncoded ¶ added in v0.3.0
func DialContext ¶
Types ¶
type Builder ¶
type Builder struct { // Timeout specifies a time limit for requests made by this // Client. The timeout includes connection time, any // redirects, and reading the response body. The timer remains // running after Get, Head, Post, or Do return and will // interrupt reading of the Response.Body. // // A Timeout of zero means no timeout. // // The Client cancels requests to the underlying Transport // using the Request.Cancel mechanism. Requests passed // to Client.Do may still set Request.Cancel; both will // cancel the request. // // For compatibility, the Client will also use the deprecated // CancelRequest method on Transport if found. New // RoundTripper implementations should use Request.Cancel // instead of implementing CancelRequest. Timeout time.Duration // Would don't use cache If nil Cache cache.Cache // Default Http1 ProtoMajor ProtoMajor Proxy Proxy SessionID string SessionTimeout time.Duration Client *http.Client }
type Charset ¶ added in v0.3.0
var ( UTF8 Charset = CharsetEncoderFunc(func(s *string) error { return nil }) GB18030 Charset = CharsetEncoderFunc(func(s *string) error { v, err := simplifiedchinese.GB18030.NewEncoder().String(*s) if err != nil { return err } *s = v return nil }) )
type CharsetEncoderFunc ¶ added in v0.3.0
func (CharsetEncoderFunc) Encode ¶ added in v0.3.0
func (c CharsetEncoderFunc) Encode(s *string) error
type HttpClient ¶
type HttpClient struct { *http.Client StoreCookie StoreCookie }
func (*HttpClient) Send ¶
func (h *HttpClient) Send(r *Request) (resp *Response)
type ProtoMajor ¶
type ProtoMajor int
const ( HTTP1 ProtoMajor HTTP2 )
func (ProtoMajor) RoundTripper ¶
func (t ProtoMajor) RoundTripper() http.RoundTripper
type Request ¶
type Request struct { Method string Url *strings.Builder Header http.Header Querys [][2]string Forms [][2]string Body io.Reader JsonData interface{} Cookies []*http.Cookie Charset Charset Client Client Config RequestConfig }
func NewPureRequest ¶ added in v0.3.0
func NewPureRequest() *Request
func NewRequest ¶
func (*Request) ClearCookie ¶
func (*Request) MethodHead ¶
func (*Request) OriginInHeader ¶
func (*Request) RefererInHeader ¶
func (*Request) SetStringCookies ¶
type RequestConfig ¶
type Response ¶
func (*Response) DetectedEncode ¶
func (*Response) DocumentDetectedEncode ¶
type StoreCookie ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.