Documentation ¶
Index ¶
- Constants
- func CreateReqCtx(ctx context.Context, ctxData *reqCtxData) context.Context
- func GetReqCtxData(ctx context.Context) *reqCtxData
- func NewDialer(option DialerOption) *net.Dialer
- func NewOrderMap() *orderMap
- func NewReqCtxData(ctx context.Context, option *RequestOption) (*reqCtxData, error)
- func ReadRequest(b *bufio.Reader) (*http.Request, error)
- type Client
- func (obj *Client) ClearCookies()
- func (obj *Client) Close()
- func (obj *Client) CloseConns()
- func (obj *Client) Connect(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Delete(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) ForceCloseConns()
- func (obj *Client) Get(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) GetCookies(href string) (Cookies, error)
- func (obj *Client) Head(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Options(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Patch(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Post(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Put(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- func (obj *Client) Request(ctx context.Context, method string, href string, options ...RequestOption) (resp *Response, err error)
- func (obj *Client) SetCookies(href string, cookies ...any) error
- func (obj *Client) SetGetProxy(getProxy func(ctx context.Context, url *url.URL) (string, error))
- func (obj *Client) SetProxy(proxyUrl string) (err error)
- func (obj *Client) Trace(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- type ClientOption
- type Cookies
- type DialClient
- type DialOption
- type DialerOption
- type Event
- type File
- type Jar
- type RequestOption
- type Response
- func Connect(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Delete(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Get(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Head(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Options(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Patch(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Post(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Put(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func Request(ctx context.Context, method string, href string, options ...RequestOption) (resp *Response, err error)
- func Trace(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
- func (obj *Response) CloseBody() error
- func (obj *Response) CloseConn()
- func (obj *Response) Content() []byte
- func (obj *Response) ContentEncoding() string
- func (obj *Response) ContentLength() int64
- func (obj *Response) ContentType() string
- func (obj *Response) Cookies() Cookies
- func (obj *Response) Decode(encoding string)
- func (obj *Response) ForceCloseConn()
- func (obj *Response) H2Ja3() string
- func (obj *Response) Headers() http.Header
- func (obj *Response) Html() *bs4.Client
- func (obj *Response) InPool() bool
- func (obj *Response) IsNewConn() bool
- func (obj *Response) IsStream() bool
- func (obj *Response) Ja3() string
- func (obj *Response) Json(vals ...any) (*gson.Client, error)
- func (obj *Response) Location() (*url.URL, error)
- func (obj *Response) Map() (data map[string]any, err error)
- func (obj *Response) Proto() string
- func (obj *Response) Proxy() string
- func (obj *Response) Read(con []byte) (i int, err error)
- func (obj *Response) ReadBody() error
- func (obj *Response) SetContent(val []byte)
- func (obj *Response) Sse() *Sse
- func (obj *Response) Status() string
- func (obj *Response) StatusCode() int
- func (obj *Response) Text() string
- func (obj *Response) Url() *url.URL
- func (obj *Response) WebSocket() *websocket.Conn
- type RoundTripper
- type Sse
Constants ¶
const ( UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + chromeV + ".0.0.0 Safari/537.36 Edg/" + chromeV + chromeE SecChUa = `"Chromium";v="%s` + chromeV + `", "Microsoft Edge";v="` + chromeV + `", "Not=A?Brand";v="99"` AcceptLanguage = "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" )
Variables ¶
This section is empty.
Functions ¶
func GetReqCtxData ¶
func NewDialer ¶
func NewDialer(option DialerOption) *net.Dialer
func NewOrderMap ¶
func NewOrderMap() *orderMap
func NewReqCtxData ¶
func NewReqCtxData(ctx context.Context, option *RequestOption) (*reqCtxData, error)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Connection Management
func NewClient ¶
func NewClient(preCtx context.Context, options ...ClientOption) (*Client, error)
New Connection Management
func (*Client) Close ¶
func (obj *Client) Close()
Close the client and cannot be used again after shutdown
func (*Client) CloseConns ¶
func (obj *Client) CloseConns()
Close idle connections. If the connection is in use, wait until it ends before closing
func (*Client) Connect ¶
func (obj *Client) Connect(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Connect request and returns the response.
func (*Client) Delete ¶
func (obj *Client) Delete(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Delete request and returns the response.
func (*Client) ForceCloseConns ¶
func (obj *Client) ForceCloseConns()
Close the connection, even if it is in use, it will be closed
func (*Client) Get ¶
func (obj *Client) Get(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Get request and returns the response.
func (*Client) Head ¶
func (obj *Client) Head(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Head request and returns the response.
func (*Client) Options ¶
func (obj *Client) Options(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Options request and returns the response.
func (*Client) Patch ¶
func (obj *Client) Patch(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Patch request and returns the response.
func (*Client) Post ¶
func (obj *Client) Post(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Post request and returns the response.
func (*Client) Put ¶
func (obj *Client) Put(ctx context.Context, href string, options ...RequestOption) (*Response, error)
sends a Put request and returns the response.
func (*Client) Request ¶
func (obj *Client) Request(ctx context.Context, method string, href string, options ...RequestOption) (resp *Response, err error)
Define a function named Request that takes in four parameters:
func (*Client) SetCookies ¶
set cookies
func (*Client) SetGetProxy ¶
Modify the proxy method of the client
type ClientOption ¶
type ClientOption struct { ForceHttp1 bool //force use http1 send requests OrderHeaders []string //order headers with http1 Ja3 bool //enable ja3 fingerprint Ja3Spec ja3.Ja3Spec //custom ja3Spec,use ja3.CreateSpecWithStr or ja3.CreateSpecWithId create H2Ja3Spec ja3.H2Ja3Spec //h2 fingerprint Proxy string //proxy,support https,http,socks5 DisCookie bool //disable cookies DisDecode bool //disable auto decode DisUnZip bool //disable auto zip decode DisAlive bool //disable keepalive Bar bool ////enable bar display Timeout time.Duration //request timeout OptionCallBack func(ctx context.Context, client *Client, option *RequestOption) error //option callback,if error is returnd, break request ResultCallBack func(ctx context.Context, client *Client, response *Response) error //result callback,if error is returnd,next errCallback ErrCallBack func(ctx context.Context, client *Client, response *Response, err error) error //error callback,if error is returnd,break request RequestCallBack func(ctx context.Context, request *http.Request, response *http.Response) error //request and response callback,if error is returnd,reponse is error MaxRetries int //try num MaxRedirectNum int //redirect num ,<0 no redirect,==0 no limit Headers any //default headers ResponseHeaderTimeout time.Duration //ResponseHeaderTimeout ,default:30 TlsHandshakeTimeout time.Duration //tls timeout,default:15 //network card ip DialTimeout time.Duration //dial tcp timeout,default:15 KeepAlive time.Duration //keepalive,default:30 LocalAddr *net.TCPAddr Dns *net.UDPAddr //dns AddrType gtls.AddrType //dns parse addr type Jar *Jar //custom cookies GetProxy func(ctx context.Context, url *url.URL) (string, error) //proxy callback:support https,http,socks5 proxy GetAddrType func(host string) gtls.AddrType }
Connection Management Options
type Cookies ¶
cookies
func ReadCookies ¶
read cookies or parse cookies,support json,map,[]string,http.Header,string
func ReadSetCookies ¶
read set cookies or parse set cookies,support json,map,[]string,http.Header,string
type DialClient ¶
type DialClient struct {
// contains filtered or unexported fields
}
func NewDail ¶
func NewDail(option DialOption) *DialClient
func (*DialClient) DialContext ¶
type DialOption ¶
type DialerOption ¶
type RequestOption ¶
type RequestOption struct { ForceHttp1 bool //force use http1 send requests OrderHeaders []string //order headers with http1 Ja3 bool //enable ja3 fingerprint Ja3Spec ja3.Ja3Spec //custom ja3Spec,use ja3.CreateSpecWithStr or ja3.CreateSpecWithId create H2Ja3Spec ja3.H2Ja3Spec //custom h2 fingerprint Proxy string //proxy,support http,https,socks5,example:http://127.0.0.1:7005 DisCookie bool //disable cookies,not use cookies DisDecode bool //disable auto decode DisUnZip bool //disable auto zip decode DisAlive bool //disable keepalive Bar bool //enable bar display Timeout time.Duration //request timeout OptionCallBack func(ctx context.Context, client *Client, option *RequestOption) error //option callback,if error is returnd, break request ResultCallBack func(ctx context.Context, client *Client, response *Response) error //result callback,if error is returnd,next errCallback ErrCallBack func(ctx context.Context, client *Client, response *Response, err error) error //error callback,if error is returnd,break request RequestCallBack func(ctx context.Context, request *http.Request, response *http.Response) error //request and response callback,if error is returnd,reponse is error MaxRetries int //try num MaxRedirectNum int //redirect num ,<0 no redirect,==0 no limit Headers any //request headers:json,map,header ResponseHeaderTimeout time.Duration //ResponseHeaderTimeout ,default:30 TlsHandshakeTimeout time.Duration //network card ip DialTimeout time.Duration //dial tcp timeout,default:15 KeepAlive time.Duration //keepalive,default:30 LocalAddr *net.TCPAddr Dns *net.UDPAddr //dns AddrType gtls.AddrType //dns parse addr type //tls timeout,default:15 Jar *Jar //custom cookies Stream bool //disable auto read Referer string //set headers referer value Method string //method Url *url.URL Host string Cookies any // cookies,support :json,map,str,http.Header Params any //url params,join url query,json,map Json any //send application/json,support io.Reader,:string,[]bytes,json,map Data any //send application/x-www-form-urlencoded, support io.Reader, string,[]bytes,json,map Form any //send multipart/form-data,file upload,support io.Reader, json,map Text any //send text/xml,support: io.Reader, string,[]bytes,json,map Body any //not setting context-type,support io.Reader, string,[]bytes,json,map ContentType string //headers Content-Type value WsOption websocket.Option //websocket option DisProxy bool //force disable proxy Debug bool //enable debugger // contains filtered or unexported fields }
Options for sending requests
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func Connect ¶
func Connect(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
sends a Connect request and returns the response.
func Options ¶
func Options(ctx context.Context, href string, options ...RequestOption) (resp *Response, err error)
sends a Options request and returns the response.
func Request ¶
func Request(ctx context.Context, method string, href string, options ...RequestOption) (resp *Response, err error)
Define a function named Request that takes in four parameters:
func (*Response) ContentEncoding ¶
return content encoding
func (*Response) SetContent ¶
set response content with []byte
type RoundTripper ¶
type RoundTripper struct {
// contains filtered or unexported fields
}