Documentation
¶
Index ¶
- Constants
- Variables
- func NewJar() *jar
- func NewRequestWithContext(ctx context.Context, method string, u *url.URL, body io.Reader) (*http.Request, error)
- func WriteUdpAddr(w io.Writer, addr Address) error
- type Address
- 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 *url.URL) Cookies
- 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) (response *Response, err error)
- func (obj *Client) SetCookies(href *url.URL, cookies ...any) error
- func (obj *Client) Trace(ctx context.Context, href string, options ...RequestOption) (*Response, error)
- type ClientOption
- type Conn
- type Cookies
- type DialOption
- type Dialer
- func (obj *Dialer) DialContext(ctx *Response, network string, addr Address) (net.Conn, error)
- func (obj *Dialer) DialProxyContext(ctx *Response, network string, proxyTlsConfig *tls.Config, ...) (net.PacketConn, net.Conn, error)
- func (obj *Dialer) ProxyDialContext(ctx *Response, network string, addr Address) (net.Conn, error)
- func (obj *Dialer) Socks5TcpProxy(ctx *Response, proxyAddr Address, remoteAddr Address) (conn net.Conn, err error)
- func (obj *Dialer) Socks5UdpProxy(ctx *Response, proxyAddress Address, remoteAddress Address) (udpConn net.PacketConn, err error)
- type Event
- type File
- type Jar
- type Log
- type LogType
- type OrderMap
- 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 NewResponse(ctx context.Context, option RequestOption) *Response
- 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) Body() io.ReadCloser
- func (obj *Response) Client() *Client
- func (obj *Response) CloseBody()
- 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) Context() context.Context
- func (obj *Response) Cookies() Cookies
- func (obj *Response) Decode(encoding string)
- func (obj *Response) Err() error
- func (obj *Response) ForceCloseConn()
- func (obj *Response) Headers() http.Header
- func (obj *Response) Html() *bs4.Client
- func (obj *Response) IsNewConn() bool
- func (obj *Response) IsSSE() bool
- func (obj *Response) IsStream() bool
- func (obj *Response) IsWebSocket() bool
- 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) Option() *RequestOption
- func (obj *Response) Proto() string
- func (obj *Response) Proxys() []Address
- func (obj *Response) ReadBody() (err error)
- func (obj *Response) Request() *http.Request
- func (obj *Response) Response() *http.Response
- func (obj *Response) SSE() *SSE
- func (obj *Response) SetContent(val []byte)
- 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 SSE
- type UDPConn
- func (c *UDPConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c *UDPConn) ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error)
- func (c *UDPConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error)
- func (c *UDPConn) SetDeadline(t time.Time) error
- func (c *UDPConn) SetReadBuffer(bytes int) error
- func (c *UDPConn) SetReadDeadline(t time.Time) error
- func (c *UDPConn) SetWriteBuffer(bytes int) error
- func (c *UDPConn) SetWriteDeadline(t time.Time) error
- func (c *UDPConn) WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error)
- func (c *UDPConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- func (c *UDPConn) WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
Constants ¶
const MaxUdpPacket int = math.MaxUint16 - 28
Variables ¶
var ErrUseLastResponse = http.ErrUseLastResponse
Functions ¶
func NewRequestWithContext ¶
Types ¶
type Address ¶
type Address struct { User string Password string Name string Host string IP net.IP Port int NetWork string Scheme string }
func GetAddressWithAddr ¶
type Client ¶
type Client struct { ClientOption ClientOption // 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) (response *Response, err error)
Define a function named Request that takes in four parameters:
func (*Client) SetCookies ¶
set cookies
type ClientOption ¶
type ClientOption struct { Logger func(Log) //debuggable H3 bool //开启http3 OrderHeaders []string //order headers Ja3Spec ja3.Spec //custom ja3Spec,use ja3.CreateSpecWithStr or ja3.CreateSpecWithId create H2Ja3Spec ja3.H2Spec //h2 fingerprint UJa3Spec ja3.USpec //h3 fingerprint Proxy string //proxy,support https,http,socks5 Proxys []string //proxy list,support https,http,socks5 ForceHttp1 bool //force use http1 send requests Ja3 bool //enable ja3 fingerprint DisCookie bool //disable cookies DisDecode bool //disable auto decode DisUnZip bool //disable auto zip decode Bar bool ////enable bar display OptionCallBack func(ctx *Response) error //option callback,if error is returnd, break request ResultCallBack func(ctx *Response) error //result callback,if error is returnd,next errCallback ErrCallBack func(ctx *Response) error //error callback,if error is returnd,break request RequestCallBack func(ctx *Response) error //request and response callback,if error is returnd,reponse is error MaxRetries int //try num MaxRedirect int //redirect num ,<0 no redirect,==0 no limit Headers any //default headers Timeout time.Duration //request timeout ResponseHeaderTimeout time.Duration //ResponseHeaderTimeout ,default:300 TlsHandshakeTimeout time.Duration //tls timeout,default:15 UserAgent string //headers User-Agent value GetProxy func(ctx *Response) (string, error) //proxy callback:support https,http,socks5 proxy GetProxys func(ctx *Response) ([]string, error) //proxys callback:support https,http,socks5 proxy DialOption DialOption Jar Jar //custom cookies TlsConfig *tls.Config UtlsConfig *utls.Config QuicConfig *quic.Config UquicConfig *uquic.Config }
Connection Management Options
type Cookies ¶
cookies
func ReadCookies ¶
read cookies or parse cookies,support json,map,[]string,http.Header,string
type DialOption ¶
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
自定义dialer
func (*Dialer) DialContext ¶
func (*Dialer) DialProxyContext ¶
func (*Dialer) ProxyDialContext ¶
func (*Dialer) Socks5TcpProxy ¶
func (*Dialer) Socks5UdpProxy ¶
type LogType ¶
type LogType string
const ( LogType_DNSLookup LogType = "DNSLookup" LogType_TCPConnect LogType = "TCPConnect" LogType_TLSHandshake LogType = "TLSHandshake" LogType_ProxyDNSLookup LogType = "ProxyDNSLookup" LogType_ProxyTCPConnect LogType = "ProxyTCPConnect" LogType_ProxyTLSHandshake LogType = "ProxyTLSHandshake" LogType_ProxyConnectRemote LogType = "ProxyConnectRemote" LogType_ResponseHeader LogType = "ResponseHeader" LogType_ResponseBody LogType = "ResponseBody" )
type OrderMap ¶
type OrderMap struct {
// contains filtered or unexported fields
}
func NewOrderMap ¶
func NewOrderMap() *OrderMap
func (*OrderMap) MarshalJSON ¶
type RequestOption ¶
type RequestOption struct { ClientOption // other option Method string //method Url *url.URL Host string Referer string //set headers referer value ContentType string //headers Content-Type value 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 Stream bool //disable auto read WsOption websocket.Option //websocket option DisProxy bool //force disable proxy // 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 NewResponse ¶
func NewResponse(ctx context.Context, option RequestOption) *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) Body ¶
func (obj *Response) Body() io.ReadCloser
func (*Response) ContentEncoding ¶
return content encoding
func (*Response) IsWebSocket ¶
return true if response is other stream
func (*Response) Option ¶
func (obj *Response) Option() *RequestOption
func (*Response) SetContent ¶
set response content with []byte
type UDPConn ¶
type UDPConn struct { net.PacketConn UDPConn *net.UDPConn // contains filtered or unexported fields }