Documentation
ΒΆ
Overview ΒΆ
Package surf provides a comprehensive HTTP client library with advanced features for web scraping, automation, and HTTP/3 support with various browser fingerprinting capabilities.
Index ΒΆ
- Constants
- type Body
- func (b *Body) Bytes() g.Result[g.Bytes]
- func (b *Body) Close() error
- func (b *Body) Contains(pattern any) bool
- func (b *Body) Dump(filename g.String) error
- func (b *Body) JSON(data any) error
- func (b *Body) Limit(limit int64) *Body
- func (b *Body) SSE(fn func(event *sse.Event) bool) error
- func (b *Body) Stream() *StreamReader
- func (b *Body) String() g.Result[g.String]
- func (b *Body) UTF8() g.Result[g.String]
- func (b *Body) WithContext(ctx context.Context) *Body
- func (b *Body) XML(data any) error
- type Builder
- func (b *Builder) AddCookies(cookies ...*http.Cookie) *Builder
- func (b *Builder) AddHeaders(headers ...any) *Builder
- func (b *Builder) BasicAuth(authentication g.String) *Builder
- func (b *Builder) BearerAuth(authentication g.String) *Builder
- func (b *Builder) Boundary(boundary func() g.String) *Builder
- func (b *Builder) Build() g.Result[*Client]
- func (b *Builder) CacheBody() *Builder
- func (b *Builder) ContentType(contentType g.String) *Builder
- func (b *Builder) DNS(dns g.String) *Builder
- func (b *Builder) DNSOverTLS() *DNSOverTLS
- func (b *Builder) DisableCompression() *Builder
- func (b *Builder) DisableKeepAlive() *Builder
- func (b *Builder) FollowOnlyHostRedirects() *Builder
- func (b *Builder) ForceHTTP1() *Builder
- func (b *Builder) ForceHTTP2() *Builder
- func (b *Builder) ForceHTTP3() *Builder
- func (b *Builder) ForwardHeadersOnRedirect() *Builder
- func (b *Builder) GetRemoteAddress() *Builder
- func (b *Builder) H2C() *Builder
- func (b *Builder) HTTP2Settings() *HTTP2Settings
- func (b *Builder) HTTP3() *Builder
- func (b *Builder) HTTP3Settings() *HTTP3Settings
- func (b *Builder) Impersonate() *Impersonate
- func (b *Builder) InterfaceAddr(address g.String) *Builder
- func (b *Builder) JA() *JA
- func (b *Builder) MaxRedirects(maxRedirects int) *Builder
- func (b *Builder) NotFollowRedirects() *Builder
- func (b *Builder) Proxy(proxy g.String) *Builder
- func (b *Builder) RedirectPolicy(fn func(*http.Request, []*http.Request) error) *Builder
- func (b *Builder) Retry(retryMax int, retryWait time.Duration, codes ...int) *Builder
- func (b *Builder) Session() *Builder
- func (b *Builder) SetHeaders(headers ...any) *Builder
- func (b Builder) String() string
- func (b *Builder) TLSConfig(config *tls.Config) *Builder
- func (b *Builder) Timeout(timeout time.Duration) *Builder
- func (b *Builder) UnixSocket(address g.String) *Builder
- func (b *Builder) UserAgent(userAgent any) *Builder
- func (b *Builder) With(middleware any, priority ...int) *Builder
- func (b *Builder) WithContext(ctx context.Context) *Builder
- type Client
- func (c *Client) Builder() *Builder
- func (c *Client) Close() error
- func (c *Client) CloseIdleConnections()
- func (c *Client) Connect(rawURL g.String) *Request
- func (c *Client) Delete(rawURL g.String) *Request
- func (c *Client) Get(rawURL g.String) *Request
- func (c *Client) GetClient() *http.Client
- func (c *Client) GetDialer() *net.Dialer
- func (c *Client) GetTLSConfig() *tls.Config
- func (c *Client) GetTransport() http.RoundTripper
- func (c *Client) Head(rawURL g.String) *Request
- func (c *Client) Options(rawURL g.String) *Request
- func (c *Client) Patch(rawURL g.String) *Request
- func (c *Client) Post(rawURL g.String) *Request
- func (c *Client) Put(rawURL g.String) *Request
- func (c *Client) Raw(raw, scheme g.String) *Request
- func (c *Client) Std() *_http.Client
- func (c *Client) Trace(rawURL g.String) *Request
- type CookieJarAdapter
- type Cookies
- type DNSOverTLS
- func (dot *DNSOverTLS) AdGuard() *Builder
- func (dot *DNSOverTLS) AddProvider(serverName g.String, addresses ...g.String) *Builder
- func (dot *DNSOverTLS) Ali() *Builder
- func (dot *DNSOverTLS) CIRAShield() *Builder
- func (dot *DNSOverTLS) Cloudflare() *Builder
- func (dot *DNSOverTLS) Forge() *Builder
- func (dot *DNSOverTLS) Google() *Builder
- func (dot *DNSOverTLS) LibreDNS() *Builder
- func (dot *DNSOverTLS) Quad9() *Builder
- func (dot *DNSOverTLS) Quad101() *Builder
- func (dot *DNSOverTLS) SB() *Builder
- func (dot *DNSOverTLS) Switch() *Builder
- type Debug
- type Err101ResponseCode
- type ErrHTTP2Fallback
- type ErrUserAgentType
- type ErrWebSocketUpgrade
- type HTTP2Settings
- func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) InitialStreamID(id uint32) *HTTP2Settings
- func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) NoRFC7540Priorities(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
- func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
- func (h *HTTP2Settings) Set() *Builder
- type HTTP3Settings
- func (h *HTTP3Settings) EnableConnectProtocol(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) EnableWebtransport(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) Grease() *HTTP3Settings
- func (h *HTTP3Settings) H3Datagram(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) MaxFieldSectionSize(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackBlockedStreams(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackMaxTableCapacity(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) Set() *Builder
- func (h *HTTP3Settings) SettingsH3Datagram(num uint64) *HTTP3Settings
- type Headers
- type Impersonate
- func (im *Impersonate) Android() *Impersonate
- func (im *Impersonate) Chrome() *Builder
- func (im *Impersonate) Firefox() *Builder
- func (im *Impersonate) FirefoxPrivate() *Builder
- func (im *Impersonate) IOS() *Impersonate
- func (im *Impersonate) Linux() *Impersonate
- func (im *Impersonate) MacOS() *Impersonate
- func (im *Impersonate) RandomOS() *Impersonate
- func (im *Impersonate) Windows() *Impersonate
- type ImpersonateOS
- type JA
- func (j *JA) Android() *Builder
- func (j *JA) Chrome() *Builder
- func (j *JA) Chrome58() *Builder
- func (j *JA) Chrome62() *Builder
- func (j *JA) Chrome70() *Builder
- func (j *JA) Chrome72() *Builder
- func (j *JA) Chrome83() *Builder
- func (j *JA) Chrome87() *Builder
- func (j *JA) Chrome96() *Builder
- func (j *JA) Chrome100() *Builder
- func (j *JA) Chrome102() *Builder
- func (j *JA) Chrome106() *Builder
- func (j *JA) Chrome120() *Builder
- func (j *JA) Chrome120PQ() *Builder
- func (j *JA) Chrome145() *Builder
- func (j *JA) Edge() *Builder
- func (j *JA) Edge85() *Builder
- func (j *JA) Edge106() *Builder
- func (j *JA) Firefox() *Builder
- func (j *JA) Firefox55() *Builder
- func (j *JA) Firefox56() *Builder
- func (j *JA) Firefox63() *Builder
- func (j *JA) Firefox65() *Builder
- func (j *JA) Firefox99() *Builder
- func (j *JA) Firefox102() *Builder
- func (j *JA) Firefox105() *Builder
- func (j *JA) Firefox120() *Builder
- func (j *JA) Firefox141() *Builder
- func (j *JA) Firefox147() *Builder
- func (j *JA) FirefoxPrivate147() *Builder
- func (j *JA) IOS() *Builder
- func (j *JA) IOS11() *Builder
- func (j *JA) IOS12() *Builder
- func (j *JA) IOS13() *Builder
- func (j *JA) IOS14() *Builder
- func (j *JA) Randomized() *Builder
- func (j *JA) RandomizedALPN() *Builder
- func (j *JA) RandomizedNoALPN() *Builder
- func (j *JA) Safari() *Builder
- func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
- func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
- type Multipart
- func (m *Multipart) ContentType(ct g.String) *Multipart
- func (m *Multipart) Field(name, value g.String) *Multipart
- func (m *Multipart) File(fieldName g.String, file *g.File) *Multipart
- func (m *Multipart) FileBytes(fieldName, fileName g.String, data g.Bytes) *Multipart
- func (m *Multipart) FileName(name g.String) *Multipart
- func (m *Multipart) FileReader(fieldName, fileName g.String, reader io.Reader) *Multipart
- func (m *Multipart) FileString(fieldName, fileName, content g.String) *Multipart
- func (m *Multipart) Retry() *Multipart
- type MultipartFile
- type Request
- func (req *Request) AddCookies(cookies ...*http.Cookie) *Request
- func (req *Request) AddHeaders(headers ...any) *Request
- func (req *Request) Body(data any) *Request
- func (req *Request) Do() g.Result[*Response]
- func (req *Request) GetRequest() *http.Request
- func (req *Request) Multipart(m *Multipart) *Request
- func (req *Request) SetHeaders(headers ...any) *Request
- func (req *Request) WithContext(ctx context.Context) *Request
- type Response
- func (resp Response) Debug() *Debug
- func (resp Response) GetCookies(rawURL g.String) []*http.Cookie
- func (resp Response) GetResponse() *http.Response
- func (resp Response) Location() g.String
- func (resp Response) Referer() g.String
- func (resp Response) RemoteAddress() net.Addr
- func (resp *Response) SetCookies(rawURL g.String, cookies []*http.Cookie) error
- func (resp Response) TLSGrabber() *TLSData
- type StatusCode
- type StreamReader
- type TLSData
- type TransportAdapter
Constants ΒΆ
const ( SETTINGS_QPACK_MAX_TABLE_CAPACITY = 0x01 SETTINGS_MAX_FIELD_SECTION_SIZE = 0x06 SETTINGS_QPACK_BLOCKED_STREAMS = 0x07 SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08 SETTINGS_H3_DATAGRAM = 0x33 H3_DATAGRAM = 0xFFD277 SETTINGS_ENABLE_WEBTRANSPORT = 0x2B603742 )
HTTP/3 SETTINGS frame parameter identifiers as defined in RFC 9114.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Body ΒΆ added in v1.0.51
type Body struct {
// Underlying body reader (usually http.Response.Body).
// Provides access to the raw response stream.
Reader io.ReadCloser
// contains filtered or unexported fields
}
Body represents an HTTP response body with enhanced functionality and automatic caching. Provides convenient methods for parsing common data formats (JSON, XML, text) and includes features like automatic decompression, content caching, character set detection, and size limits.
func (*Body) Close ΒΆ added in v1.0.51
Close closes the body and returns any error encountered. It drains remaining data for connection reuse, but respects context cancellation.
func (*Body) Contains ΒΆ added in v1.0.51
Contains checks if the body's content contains the provided pattern (byte slice, string, or *regexp.Regexp) and returns a boolean.
func (*Body) Dump ΒΆ added in v1.0.51
Dump dumps the body's content to a file with the given filename.
func (*Body) JSON ΒΆ added in v1.0.51
JSON decodes the body's content as JSON into the provided data structure.
func (*Body) Limit ΒΆ added in v1.0.51
Limit sets the body's size limit and returns the modified body.
func (*Body) SSE ΒΆ added in v1.0.53
SSE reads the body's content as Server-Sent Events (SSE) and calls the provided function for each event. It expects the function to take an *sse.Event pointer as its argument and return a boolean value. If the function returns false, the SSE reading stops.
func (*Body) Stream ΒΆ added in v1.0.51
func (b *Body) Stream() *StreamReader
Stream returns a bufio.Reader for streaming the body content. IMPORTANT: Call this method once and reuse the returned reader. Each call creates a new bufio.Reader; calling repeatedly in a loop will lose buffered data.
func (*Body) UTF8 ΒΆ added in v1.0.51
UTF8 converts the body's content to UTF-8 encoding and returns it as a string.
func (*Body) WithContext ΒΆ added in v1.0.185
WithContext sets the context for cancellation of read operations.
Must be called BEFORE reading the body (Bytes(), String(), Stream(), etc.). Silently ignored if reading has already started.
type Builder ΒΆ added in v1.0.100
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent interface for configuring HTTP clients with various advanced features including proxy settings, TLS fingerprinting, HTTP/2 and HTTP/3 support, retry logic, redirect handling, and browser impersonation capabilities.
func (*Builder) AddCookies ΒΆ added in v1.0.100
AddCookies adds cookies to the request.
func (*Builder) AddHeaders ΒΆ added in v1.0.100
AddHeaders adds headers to the request, appending to any existing headers with the same name.
func (*Builder) BasicAuth ΒΆ added in v1.0.100
BasicAuth sets the basic authentication credentials for the client.
func (*Builder) BearerAuth ΒΆ added in v1.0.100
BearerAuth sets the bearer token for the client.
func (*Builder) Build ΒΆ added in v1.0.100
Build applies all configured settings and returns the client. Returns g.Result with error if any middleware fails.
func (*Builder) CacheBody ΒΆ added in v1.0.100
CacheBody configures whether the client should cache the body of the response.
func (*Builder) ContentType ΒΆ added in v1.0.100
ContentType sets the content type for the client.
func (*Builder) DNSOverTLS ΒΆ added in v1.0.100
func (b *Builder) DNSOverTLS() *DNSOverTLS
DNSOverTLS configures the client to use DNS over TLS.
func (*Builder) DisableCompression ΒΆ added in v1.0.100
DisableCompression disables automatic response body decompression.
func (*Builder) DisableKeepAlive ΒΆ added in v1.0.100
DisableKeepAlive disable keep-alive connections.
func (*Builder) FollowOnlyHostRedirects ΒΆ added in v1.0.100
FollowOnlyHostRedirects configures whether the client should only follow redirects within the same host.
func (*Builder) ForceHTTP1 ΒΆ added in v1.0.100
ForceHTTP1 configures the client to use HTTP/1.1 forcefully.
func (*Builder) ForceHTTP2 ΒΆ added in v1.0.147
ForceHTTP2 configures the client to use HTTP/2 forcefully.
func (*Builder) ForceHTTP3 ΒΆ added in v1.0.154
ForceHTTP3 configures the client to use HTTP/3 forcefully.
func (*Builder) ForwardHeadersOnRedirect ΒΆ added in v1.0.100
ForwardHeadersOnRedirect adds a middleware to the ClientBuilder object that ensures HTTP headers are forwarded during a redirect.
func (*Builder) GetRemoteAddress ΒΆ added in v1.0.100
GetRemoteAddress configures whether the client should get the remote address.
func (*Builder) H2C ΒΆ added in v1.0.100
H2C configures the client to handle HTTP/2 Cleartext (h2c).
func (*Builder) HTTP2Settings ΒΆ added in v1.0.100
func (b *Builder) HTTP2Settings() *HTTP2Settings
HTTP2Settings configures settings related to HTTP/2 and returns an http2s struct.
func (*Builder) HTTP3Settings ΒΆ added in v1.0.101
func (b *Builder) HTTP3Settings() *HTTP3Settings
HTTP3Settings configures settings related to HTTP/3 and returns an http3s struct.
func (*Builder) Impersonate ΒΆ added in v1.0.100
func (b *Builder) Impersonate() *Impersonate
Impersonate configures something related to impersonation and returns an impersonate struct.
func (*Builder) InterfaceAddr ΒΆ added in v1.0.100
InterfaceAddr sets the local network interface for outbound connections. Accepts either an IP address (e.g., "192.168.1.100", "::1") or an interface name (e.g., "eth0", "en0").
func (*Builder) MaxRedirects ΒΆ added in v1.0.100
MaxRedirects sets the maximum number of redirects the client should follow.
func (*Builder) NotFollowRedirects ΒΆ added in v1.0.100
NotFollowRedirects disables following redirects for the client.
func (*Builder) RedirectPolicy ΒΆ added in v1.0.100
RedirectPolicy sets a custom redirect policy for the client.
func (*Builder) Retry ΒΆ added in v1.0.100
Retry configures the retry behavior of the client.
Parameters:
retryMax: Maximum number of retries to be attempted.
retryWait: Duration to wait between retries.
codes: Optional list of HTTP status codes that trigger retries.
If no codes are provided, default codes will be used
(500, 429, 503 - Internal Server Error, Too Many Requests, Service Unavailable).
func (*Builder) Session ΒΆ added in v1.0.100
Session configures whether the client should maintain a session.
func (*Builder) SetHeaders ΒΆ added in v1.0.100
SetHeaders sets headers for the request, replacing existing ones with the same name.
func (Builder) String ΒΆ added in v1.0.100
String generate a string representation of the ClientBuilder instance.
func (*Builder) TLSConfig ΒΆ added in v1.0.188
TLSConfig sets a custom TLS configuration for the client.
func (*Builder) UnixSocket ΒΆ added in v1.0.137
UnixSocket sets the path for a Unix domain socket. This allows the HTTP client to connect to the server using a Unix domain socket instead of a traditional TCP/IP connection.
func (*Builder) With ΒΆ added in v1.0.100
With registers middleware into the client builder with optional priority.
It accepts one of the following middleware function types:
- func(*surf.Client) error β client middleware, modifies or initializes the client
- func(*surf.Request) error β request middleware, intercepts or transforms outgoing requests
- func(*surf.Response) error β response middleware, intercepts or transforms incoming responses
Parameters:
- middleware: A function matching one of the supported middleware types.
- priority (optional): Integer priority level. Lower values run earlier. Defaults to 0.
Middleware with the same priority are executed in order of insertion (FIFO). If the middleware type is not recognized, With panics with an informative error.
Example:
// Adding client middleware to modify client settings.
.With(func(client *surf.Client) error {
// Custom logic to modify the client settings.
return nil
})
// Adding request middleware to intercept outgoing requests.
.With(func(req *surf.Request) error {
// Custom logic to modify outgoing requests.
return nil
})
// Adding response middleware to intercept incoming responses.
.With(func(resp *surf.Response) error {
// Custom logic to handle incoming responses.
return nil
})
Note: Ensure that middleware functions adhere to the specified function signatures to work correctly with the With method.
type Client ΒΆ
type Client struct {
// contains filtered or unexported fields
}
Client represents a highly configurable HTTP client with middleware support, advanced transport options (HTTP/1.1, HTTP/2, HTTP/3), proxy handling, TLS fingerprinting, and comprehensive request/response processing capabilities.
func NewClient ΒΆ
func NewClient() *Client
NewClient creates a new Client with sensible default settings including default dialer, TLS configuration, HTTP transport, and basic middleware.
func (*Client) Builder ΒΆ added in v1.0.50
Builder returns a new Builder instance associated with this client. The builder allows for method chaining to configure various client options.
func (*Client) Close ΒΆ added in v1.0.170
Close completely shuts down the client and releases all resources. After calling Close, the client should not be used.
func (*Client) CloseIdleConnections ΒΆ
func (c *Client) CloseIdleConnections()
CloseIdleConnections closes idle connections while keeping the client usable. Safe to call periodically to free resources during long-running operations.
func (*Client) Connect ΒΆ added in v1.0.193
Connect creates a new HTTP CONNECT request for the specified URL. CONNECT requests are used to establish a tunnel to the server.
func (*Client) Delete ΒΆ
Delete creates a new HTTP DELETE request for the specified URL. DELETE requests are used to remove a resource from a server.
func (*Client) Get ΒΆ
Get creates a new HTTP GET request for the specified URL. GET requests are used to retrieve data from a server.
func (*Client) GetTLSConfig ΒΆ
GetTLSConfig returns the tls.Config used by the Client.
func (*Client) GetTransport ΒΆ
func (c *Client) GetTransport() http.RoundTripper
GetTransport returns the http.transport used by the Client.
func (*Client) Head ΒΆ
Head creates a new HTTP HEAD request for the specified URL. HEAD requests are identical to GET but without the response body.
func (*Client) Options ΒΆ added in v1.0.193
Options creates a new HTTP OPTIONS request for the specified URL. OPTIONS requests are used to describe the communication options for a resource.
func (*Client) Patch ΒΆ
Patch creates a new HTTP PATCH request for the specified URL. PATCH requests are used to apply partial modifications to a resource.
func (*Client) Post ΒΆ
Post creates a new HTTP POST request for the specified URL. POST requests are used to submit data to a server.
func (*Client) Put ΒΆ
Put creates a new HTTP PUT request for the specified URL. PUT requests are used to replace a resource on a server.
func (*Client) Raw ΒΆ
Raw creates a new HTTP request using the provided raw data and scheme. The raw parameter should contain the raw HTTP request data as a string. The scheme parameter specifies the scheme (e.g., http, https) for the request.
func (*Client) Std ΒΆ added in v1.0.100
Std returns a standard net/http.Client that wraps the configured surf client. This is useful for integrating with third-party libraries that expect a standard net/http.Client while preserving most surf features.
Supported features:
- JA3/TLS fingerprinting
- HTTP/2 settings
- Cookies and sessions
- Request/Response middleware
- Headers (User-Agent, custom headers)
- Proxy configuration
- Timeout settings
- Redirect policies
- Impersonate browser headers
Known limitations:
- Retry logic is NOT supported (implemented in Request.Do(), not in transport)
- Response body caching is NOT supported
- Remote address tracking is NOT supported
- Request timing information is NOT available
For applications requiring retry logic, consider implementing it at the application level or use surf.Client directly for those specific requests.
Example usage:
surfClient := surf.NewClient().
Builder().
JA3().Chrome().
Session().
Build()
// For libraries expecting net/http.Client
stdClient := surfClient.Std()
botClient := &BaseBotClient{
Client: *stdClient,
}
type CookieJarAdapter ΒΆ added in v1.0.100
type CookieJarAdapter struct {
// contains filtered or unexported fields
}
CookieJarAdapter adapts github.com/enetx/http.CookieJar to net/http.CookieJar. It provides bidirectional cookie conversion between the two HTTP packages, ensuring cookies set through either interface work correctly.
func (*CookieJarAdapter) Cookies ΒΆ added in v1.0.100
func (c *CookieJarAdapter) Cookies(u *url.URL) []*_http.Cookie
Cookies implements http.CookieJar interface. It retrieves cookies from the underlying surf cookie jar and converts them to standard net/http cookie format.
func (*CookieJarAdapter) SetCookies ΒΆ added in v1.0.100
func (c *CookieJarAdapter) SetCookies(u *url.URL, _cookies []*_http.Cookie)
SetCookies implements http.CookieJar interface. It converts standard net/http cookies to enetx/http format and delegates to the underlying surf cookie jar.
type Cookies ΒΆ added in v1.0.51
Cookies represents a list of HTTP Cookies.
type DNSOverTLS ΒΆ added in v1.0.100
type DNSOverTLS struct {
// contains filtered or unexported fields
}
DNSOverTLS is a configuration struct for DNS over TLS settings.
func (*DNSOverTLS) AdGuard ΒΆ added in v1.0.100
func (dot *DNSOverTLS) AdGuard() *Builder
AdGuard sets up DNS over TLS with AdGuard DNS.
func (*DNSOverTLS) AddProvider ΒΆ added in v1.0.100
AddProvider sets up DNS over TLS with a custom DNS provider. It configures a custom net.Resolver using the resolver method.
func (*DNSOverTLS) Ali ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Ali() *Builder
Ali sets up DNS over TLS with AliDNS.
func (*DNSOverTLS) CIRAShield ΒΆ added in v1.0.100
func (dot *DNSOverTLS) CIRAShield() *Builder
CIRAShield sets up DNS over TLS with CIRA Canadian Shield DNS.
func (*DNSOverTLS) Cloudflare ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Cloudflare() *Builder
Cloudflare sets up DNS over TLS with Cloudflare DNS.
func (*DNSOverTLS) Forge ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Forge() *Builder
Forge sets up DNS over TLS with DNS Forge.
func (*DNSOverTLS) Google ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Google() *Builder
Google sets up DNS over TLS with Google Public DNS.
func (*DNSOverTLS) LibreDNS ΒΆ added in v1.0.100
func (dot *DNSOverTLS) LibreDNS() *Builder
LibreDNS sets up DNS over TLS with LibreDNS.
func (*DNSOverTLS) Quad9 ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Quad9() *Builder
Quad9 sets up DNS over TLS with Quad9 DNS.
func (*DNSOverTLS) Quad101 ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Quad101() *Builder
Quad101 sets up DNS over TLS with Quad101 DNS.
func (*DNSOverTLS) SB ΒΆ added in v1.0.100
func (dot *DNSOverTLS) SB() *Builder
SB sets up DNS over TLS with Secure DNS (dot.sb).
func (*DNSOverTLS) Switch ΒΆ added in v1.0.100
func (dot *DNSOverTLS) Switch() *Builder
Switch sets up DNS over TLS with SWITCH DNS.
type Debug ΒΆ added in v1.0.100
type Debug struct {
// contains filtered or unexported fields
}
Debug is a struct that holds debugging information for an HTTP response.
func (*Debug) Print ΒΆ added in v1.0.100
func (d *Debug) Print()
Print prints the debug information.
type Err101ResponseCode ΒΆ added in v1.0.100
type Err101ResponseCode struct{ Msg string }
Err101ResponseCode indicates a 101 Switching Protocols response was received. This error is used to handle HTTP 101 responses that require protocol upgrades.
func (*Err101ResponseCode) Error ΒΆ added in v1.0.100
func (e *Err101ResponseCode) Error() string
type ErrHTTP2Fallback ΒΆ added in v1.0.179
ErrHTTP2Fallback indicates that an HTTPS request attempted HTTP/2 first, then tried to fall back to HTTP/1.1, but both attempts failed.
Both underlying errors are accessible via Unwrap, enabling errors.Is and errors.As to match against either the HTTP/2 or HTTP/1.1 failure.
func (*ErrHTTP2Fallback) Error ΒΆ added in v1.0.179
func (e *ErrHTTP2Fallback) Error() string
func (*ErrHTTP2Fallback) Unwrap ΒΆ added in v1.0.179
func (e *ErrHTTP2Fallback) Unwrap() []error
type ErrUserAgentType ΒΆ added in v1.0.100
type ErrUserAgentType struct{ Msg string }
ErrUserAgentType indicates an invalid user agent type was provided. This error is returned when the user agent parameter is not of a supported type (string, g.String, slices, etc.).
func (*ErrUserAgentType) Error ΒΆ added in v1.0.100
func (e *ErrUserAgentType) Error() string
type ErrWebSocketUpgrade ΒΆ added in v1.0.100
type ErrWebSocketUpgrade struct{ Msg string }
ErrWebSocketUpgrade indicates that a request received a WebSocket upgrade response. This error is returned when the server responds with HTTP 101 Switching Protocols for WebSocket connections, which require special handling.
func (*ErrWebSocketUpgrade) Error ΒΆ added in v1.0.100
func (e *ErrWebSocketUpgrade) Error() string
type HTTP2Settings ΒΆ added in v1.0.100
type HTTP2Settings struct {
// contains filtered or unexported fields
}
HTTP2Settings represents HTTP/2 settings. https://lwthiker.com/networks/2022/06/17/http2-fingerprinting.html
func (*HTTP2Settings) ConnectionFlow ΒΆ added in v1.0.100
func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
ConnectionFlow sets the flow control for the HTTP/2 connection.
func (*HTTP2Settings) EnablePush ΒΆ added in v1.0.100
func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
EnablePush enables HTTP/2 server push functionality.
func (*HTTP2Settings) HeaderTableSize ΒΆ added in v1.0.100
func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
HeaderTableSize sets the header table size for HTTP/2 settings.
func (*HTTP2Settings) InitialStreamID ΒΆ added in v1.0.150
func (h *HTTP2Settings) InitialStreamID(id uint32) *HTTP2Settings
InitialStreamID sets the initial stream id for HTTP/2 streams.
func (*HTTP2Settings) InitialWindowSize ΒΆ added in v1.0.100
func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
InitialWindowSize sets the initial window size for HTTP/2 streams.
func (*HTTP2Settings) MaxConcurrentStreams ΒΆ added in v1.0.100
func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
MaxConcurrentStreams sets the maximum number of concurrent streams in HTTP/2.
func (*HTTP2Settings) MaxFrameSize ΒΆ added in v1.0.100
func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
MaxFrameSize sets the maximum frame size for HTTP/2 frames.
func (*HTTP2Settings) MaxHeaderListSize ΒΆ added in v1.0.100
func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
MaxHeaderListSize sets the maximum size of the header list in HTTP/2.
func (*HTTP2Settings) NoRFC7540Priorities ΒΆ added in v1.0.166
func (h *HTTP2Settings) NoRFC7540Priorities(size uint32) *HTTP2Settings
NoRFC7540Priorities disables RFC 7540 priority signaling in HTTP/2.
func (*HTTP2Settings) PriorityFrames ΒΆ added in v1.0.100
func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
PriorityFrames sets the priority frames for HTTP/2.
func (*HTTP2Settings) PriorityParam ΒΆ added in v1.0.100
func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
PriorityParam sets the priority parameter for HTTP/2.
func (*HTTP2Settings) Set ΒΆ added in v1.0.100
func (h *HTTP2Settings) Set() *Builder
Set applies the accumulated HTTP/2 settings. It configures the HTTP/2 settings for the surf client.
type HTTP3Settings ΒΆ added in v1.0.101
type HTTP3Settings struct {
// contains filtered or unexported fields
}
HTTP3Settings provides a fluent interface for configuring HTTP/3 SETTINGS parameters. These settings are sent to the server during connection establishment.
func (*HTTP3Settings) EnableConnectProtocol ΒΆ added in v1.0.155
func (h *HTTP3Settings) EnableConnectProtocol(num uint64) *HTTP3Settings
EnableConnectProtocol enables the extended CONNECT protocol (RFC 9220).
func (*HTTP3Settings) EnableWebtransport ΒΆ added in v1.0.155
func (h *HTTP3Settings) EnableWebtransport(num uint64) *HTTP3Settings
EnableWebtransport enables WebTransport support over HTTP/3.
func (*HTTP3Settings) Grease ΒΆ added in v1.0.155
func (h *HTTP3Settings) Grease() *HTTP3Settings
Grease adds a GREASE parameter with random ID and value to prevent protocol ossification.
func (*HTTP3Settings) H3Datagram ΒΆ added in v1.0.155
func (h *HTTP3Settings) H3Datagram(num uint64) *HTTP3Settings
H3Datagram sets a custom H3_DATAGRAM value for datagram support.
func (*HTTP3Settings) MaxFieldSectionSize ΒΆ added in v1.0.155
func (h *HTTP3Settings) MaxFieldSectionSize(num uint64) *HTTP3Settings
MaxFieldSectionSize sets the maximum size of a field section the peer is willing to accept.
func (*HTTP3Settings) QpackBlockedStreams ΒΆ added in v1.0.155
func (h *HTTP3Settings) QpackBlockedStreams(num uint64) *HTTP3Settings
QpackBlockedStreams sets the maximum number of streams that can be blocked on QPACK.
func (*HTTP3Settings) QpackMaxTableCapacity ΒΆ added in v1.0.155
func (h *HTTP3Settings) QpackMaxTableCapacity(num uint64) *HTTP3Settings
QpackMaxTableCapacity sets the maximum dynamic table capacity for QPACK.
func (*HTTP3Settings) Set ΒΆ added in v1.0.101
func (h *HTTP3Settings) Set() *Builder
Set applies the configured HTTP/3 settings to the client's transport.
func (*HTTP3Settings) SettingsH3Datagram ΒΆ added in v1.0.155
func (h *HTTP3Settings) SettingsH3Datagram(num uint64) *HTTP3Settings
SettingsH3Datagram sets the H3_DATAGRAM setting value.
type Headers ΒΆ added in v1.0.51
Headers represents a collection of HTTP Headers.
func (Headers) Contains ΒΆ added in v1.0.51
Contains checks if the header contains any of the specified patterns. It accepts a header name and a pattern (or list of patterns) and returns a boolean value indicating whether any of the patterns are found in the header values. The patterns can be a string, a slice of strings, or a slice of *regexp.Regexp.
func (Headers) Del ΒΆ added in v1.0.164
Del deletes the values associated with a specified header key. It wraps the Del method from the textproto.MIMEHeader type.
type Impersonate ΒΆ added in v1.0.100
type Impersonate struct {
// contains filtered or unexported fields
}
func (*Impersonate) Android ΒΆ added in v1.0.100
func (im *Impersonate) Android() *Impersonate
Android sets the OS to Android.
func (*Impersonate) Chrome ΒΆ added in v1.0.100
func (im *Impersonate) Chrome() *Builder
Chrome impersonates Chrome browser v145.
func (*Impersonate) Firefox ΒΆ added in v1.0.156
func (im *Impersonate) Firefox() *Builder
Firefox impersonates Firefox browser v147.
func (*Impersonate) FirefoxPrivate ΒΆ added in v1.0.156
func (im *Impersonate) FirefoxPrivate() *Builder
FirefoxPrivate impersonates Firefox private browser v147.
func (*Impersonate) IOS ΒΆ added in v1.0.100
func (im *Impersonate) IOS() *Impersonate
IOS sets the OS to iOS.
func (*Impersonate) Linux ΒΆ added in v1.0.100
func (im *Impersonate) Linux() *Impersonate
Linux sets the OS to Linux.
func (*Impersonate) MacOS ΒΆ added in v1.0.100
func (im *Impersonate) MacOS() *Impersonate
MacOS sets the OS to macOS.
func (*Impersonate) RandomOS ΒΆ added in v1.0.100
func (im *Impersonate) RandomOS() *Impersonate
RandomOS selects a random OS (Windows, macOS, Linux, Android, or iOS) for the impersonate.
func (*Impersonate) Windows ΒΆ added in v1.0.100
func (im *Impersonate) Windows() *Impersonate
Windows sets the OS to Windows.
type ImpersonateOS ΒΆ added in v1.0.100
type ImpersonateOS int
ImpersonateOS defines the operating system to impersonate in User-Agent strings.
type JA ΒΆ added in v1.0.100
type JA struct {
// contains filtered or unexported fields
}
JA provides JA3/4 TLS fingerprinting capabilities for HTTP clients. JA is a method for creating SSL/TLS client fingerprints to identify and classify malware or other applications. This struct allows configuring various TLS ClientHello specifications to mimic different browsers and applications for advanced HTTP client behavior.
Reference: https://lwthiker.com/networks/2022/06/17/tls-fingerprinting.html
func (*JA) Android ΒΆ added in v1.0.100
Android sets the JA3/4 fingerprint to mimic Android 11 OkHttp client.
func (*JA) Chrome ΒΆ added in v1.0.100
Chrome sets the JA3/4 fingerprint to mimic the latest Chrome browser (auto-detection).
func (*JA) Chrome58 ΒΆ added in v1.0.100
Chrome58 sets the JA3/4 fingerprint to mimic Chrome version 58.
func (*JA) Chrome62 ΒΆ added in v1.0.100
Chrome62 sets the JA3/4 fingerprint to mimic Chrome version 62.
func (*JA) Chrome70 ΒΆ added in v1.0.100
Chrome70 sets the JA3/4 fingerprint to mimic Chrome version 70.
func (*JA) Chrome72 ΒΆ added in v1.0.100
Chrome72 sets the JA3/4 fingerprint to mimic Chrome version 72.
func (*JA) Chrome83 ΒΆ added in v1.0.100
Chrome83 sets the JA3/4 fingerprint to mimic Chrome version 83.
func (*JA) Chrome87 ΒΆ added in v1.0.100
Chrome87 sets the JA3/4 fingerprint to mimic Chrome version 87.
func (*JA) Chrome96 ΒΆ added in v1.0.100
Chrome96 sets the JA3/4 fingerprint to mimic Chrome version 96.
func (*JA) Chrome100 ΒΆ added in v1.0.100
Chrome100 sets the JA3/4 fingerprint to mimic Chrome version 100.
func (*JA) Chrome102 ΒΆ added in v1.0.100
Chrome102 sets the JA3/4 fingerprint to mimic Chrome version 102.
func (*JA) Chrome106 ΒΆ added in v1.0.100
Chrome106 sets the JA3/4 fingerprint to mimic Chrome version 106 with shuffled extensions.
func (*JA) Chrome120 ΒΆ added in v1.0.100
Chrome120 sets the JA3/4 fingerprint to mimic Chrome version 120.
func (*JA) Chrome120PQ ΒΆ added in v1.0.100
Chrome120PQ sets the JA3/4 fingerprint to mimic Chrome version 120 with post-quantum cryptography support.
func (*JA) Chrome145 ΒΆ added in v1.0.195
Chrome145 sets the JA3/4 fingerprint to mimic Chrome version 145.
func (*JA) Edge ΒΆ added in v1.0.100
Edge sets the JA3/4 fingerprint to mimic Microsoft Edge version 85.
func (*JA) Edge85 ΒΆ added in v1.0.100
Edge85 sets the JA3/4 fingerprint to mimic Microsoft Edge version 85.
func (*JA) Edge106 ΒΆ added in v1.0.100
Edge106 sets the JA3/4 fingerprint to mimic Microsoft Edge version 106.
func (*JA) Firefox ΒΆ added in v1.0.100
Firefox sets the JA3/4 fingerprint to mimic the latest Firefox browser (auto-detection).
func (*JA) Firefox55 ΒΆ added in v1.0.100
Firefox55 sets the JA3/4 fingerprint to mimic Firefox version 55.
func (*JA) Firefox56 ΒΆ added in v1.0.100
Firefox56 sets the JA3/4 fingerprint to mimic Firefox version 56.
func (*JA) Firefox63 ΒΆ added in v1.0.100
Firefox63 sets the JA3/4 fingerprint to mimic Firefox version 63.
func (*JA) Firefox65 ΒΆ added in v1.0.100
Firefox65 sets the JA3/4 fingerprint to mimic Firefox version 65.
func (*JA) Firefox99 ΒΆ added in v1.0.100
Firefox99 sets the JA3/4 fingerprint to mimic Firefox version 99.
func (*JA) Firefox102 ΒΆ added in v1.0.100
Firefox102 sets the JA3/4 fingerprint to mimic Firefox version 102.
func (*JA) Firefox105 ΒΆ added in v1.0.100
Firefox105 sets the JA3/4 fingerprint to mimic Firefox version 105.
func (*JA) Firefox120 ΒΆ added in v1.0.100
Firefox120 sets the JA3/4 fingerprint to mimic Firefox version 120.
func (*JA) Firefox141 ΒΆ added in v1.0.122
Firefox141 sets the JA3/4 fingerprint to mimic Firefox version 141.
func (*JA) Firefox147 ΒΆ added in v1.0.167
Firefox147 sets the JA3/4 fingerprint to mimic Firefox version 147.
func (*JA) FirefoxPrivate147 ΒΆ added in v1.0.167
FirefoxPrivate147 sets the JA3/4 fingerprint to mimic Firefox private version 147.
func (*JA) IOS ΒΆ added in v1.0.100
IOS sets the JA3/4 fingerprint to mimic the latest iOS Safari browser (auto-detection).
func (*JA) Randomized ΒΆ added in v1.0.100
Randomized sets a completely randomized JA3/4 fingerprint.
func (*JA) RandomizedALPN ΒΆ added in v1.0.100
RandomizedALPN sets a randomized JA3/4 fingerprint with ALPN (Application-Layer Protocol Negotiation).
func (*JA) RandomizedNoALPN ΒΆ added in v1.0.100
RandomizedNoALPN sets a randomized JA3/4 fingerprint without ALPN.
func (*JA) Safari ΒΆ added in v1.0.100
Safari sets the JA3/4 fingerprint to mimic the latest Safari browser (auto-detection).
func (*JA) SetHelloID ΒΆ added in v1.0.100
func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
SetHelloID sets a ClientHelloID for the TLS connection.
The provided ClientHelloID is used to customize the TLS handshake. This should be a valid identifier that can be mapped to a specific ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloID(utls.HelloChrome_Auto)
func (*JA) SetHelloSpec ΒΆ added in v1.0.100
func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
SetHelloSpec sets a custom ClientHelloSpec for the TLS connection.
This method allows you to set a custom ClientHelloSpec to be used during the TLS handshake. The provided spec should be a valid ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloSpec(spec)
type Multipart ΒΆ added in v1.0.181
type Multipart struct {
// contains filtered or unexported fields
}
Multipart represents multipart form data with fields and files.
func NewMultipart ΒΆ added in v1.0.181
func NewMultipart() *Multipart
NewMultipart creates a new empty Multipart object.
func (*Multipart) ContentType ΒΆ added in v1.0.181
ContentType sets the content type for the last added file. Must be called immediately after File/FileReader/FileString/FileBytes.
func (*Multipart) FileBytes ΒΆ added in v1.0.181
FileBytes adds a file from byte slice to the multipart.
func (*Multipart) FileName ΒΆ added in v1.0.181
FileName overrides the filename for the last added file. Useful when you want a different name than the physical file.
func (*Multipart) FileReader ΒΆ added in v1.0.181
FileReader adds a file from io.Reader to the multipart.
func (*Multipart) FileString ΒΆ added in v1.0.181
FileString adds a file from string content to the multipart.
func (*Multipart) Retry ΒΆ added in v1.0.184
Retry controls whether the multipart body should be buffered in memory to support retries on status codes (429, 503, 5xx, etc.).
When set, the body is fully read into memory before sending, allowing the client to replay it on retry.
Recommended only for small requests (β€ 5β10 MB).
type MultipartFile ΒΆ added in v1.0.181
type MultipartFile struct {
// contains filtered or unexported fields
}
MultipartFile represents a single file for multipart upload.
type Request ΒΆ
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request with additional surf-specific functionality. It wraps the standard http.Request and provides enhanced features like middleware support, retry capabilities, remote address tracking, and structured error handling.
func (*Request) AddCookies ΒΆ
AddCookies adds one or more HTTP cookies to the request. Cookies are added to the request headers and will be sent with the HTTP request. Returns the request for method chaining.
func (*Request) AddHeaders ΒΆ
AddHeaders adds HTTP headers to the request, appending to any existing headers with the same name. Unlike SetHeaders, this method preserves existing headers and adds new values. Supports the same input formats as SetHeaders. Returns the request for method chaining.
func (*Request) Body ΒΆ added in v1.0.181
Body sets the request body from various data types. Supported types include: []byte, string, g.String, g.Bytes, map[string]string, g.Map, g.MapOrd, and structs with json/xml tags. The Content-Type header is automatically detected and set based on the data. Returns the request for method chaining.
func (*Request) Do ΒΆ
Do executes the HTTP request and returns a Response wrapped in a Result type. This is the main method that performs the actual HTTP request with full surf functionality: - Applies request middleware (authentication, headers, tracing, etc.) - Preserves request body for potential retries - Implements retry logic with configurable status codes and delays - Measures request timing for performance analysis - Handles request preparation errors and write errors
func (*Request) GetRequest ΒΆ
GetRequest returns the underlying standard http.Request. Provides access to the wrapped HTTP request for advanced use cases.
func (*Request) Multipart ΒΆ added in v1.0.181
Multipart sets multipart form data for the request. The provided Multipart object contains form fields and files to be sent. Returns the request for method chaining. If m is nil, an error is set on the request.
func (*Request) SetHeaders ΒΆ
SetHeaders sets HTTP headers for the request, replacing any existing headers with the same name. Supports multiple input formats: - Two arguments: key, value (string or g.String) - Single argument: http.Header, Headers, map types, or g.Map types Maintains header order for fingerprinting purposes when using g.MapOrd. Returns the request for method chaining.
func (*Request) WithContext ΒΆ
WithContext associates a context with the request for cancellation and deadlines. The context can be used to cancel the request, set timeouts, or pass request-scoped values. Returns the request for method chaining. If ctx is nil, the request is unchanged.
type Response ΒΆ
type Response struct {
Headers Headers // Response headers with convenience methods
Cookies Cookies // Response cookies with enhanced functionality
UserAgent g.String // User agent that was used for the request
Proto g.String // HTTP protocol version (HTTP/1.1, HTTP/2, HTTP/3)
*Client // Embedded client provides access to all client functionality
URL *url.URL // Final URL after following redirects
Body *Body // Enhanced response body with compression support and caching
Time time.Duration // Total request duration including retries
ContentLength int64 // Content-Length header value (-1 if not specified)
StatusCode StatusCode // HTTP status code with convenience methods
Attempts int // Number of retry attempts made for this request
// contains filtered or unexported fields
}
Response represents an HTTP response with enhanced functionality and metadata. It wraps the standard http.Response and provides additional features like timing information, retry attempts tracking, enhanced cookie management, and convenient access methods.
func (Response) GetCookies ΒΆ
GetCookies returns all cookies from the response that would be sent to the specified URL. Filters cookies based on domain, path, and security attributes.
func (Response) GetResponse ΒΆ
GetResponse returns the underlying standard http.Response. Provides access to the wrapped HTTP response for advanced use cases.
func (Response) Location ΒΆ added in v1.0.47
Location returns the HTTP Location header value, typically used in redirects. Contains the URL that the client should redirect to for 3xx status codes.
func (Response) Referer ΒΆ
Referer returns the HTTP Referer header value from the original request. This indicates which page linked to the resource being requested.
func (Response) RemoteAddress ΒΆ
RemoteAddress returns the network address of the server that sent this response. Useful for logging, debugging, or connection analysis.
func (*Response) SetCookies ΒΆ
SetCookies stores cookies in the client's cookie jar for the specified URL. This allows the cookies to be automatically sent with future requests to matching URLs.
func (Response) TLSGrabber ΒΆ
TLSGrabber extracts TLS connection information from the response. Returns detailed TLS connection data including certificates, cipher suites, and protocol version if the response was received over a TLS connection. Returns nil for non-TLS connections.
type StatusCode ΒΆ added in v1.0.47
type StatusCode int
StatusCode represents an HTTP status code with convenient classification methods. Extends the basic integer status code with methods to easily identify the response category.
func (StatusCode) IsClientError ΒΆ added in v1.0.47
func (s StatusCode) IsClientError() bool
IsClientError returns true if the status code indicates a client error [400, 500].
func (StatusCode) IsInformational ΒΆ added in v1.0.47
func (s StatusCode) IsInformational() bool
IsInformational returns true if the status code is in the informational range [100, 200].
func (StatusCode) IsRedirection ΒΆ added in v1.0.47
func (s StatusCode) IsRedirection() bool
IsRedirection returns true if the status code indicates a redirection [300, 400].
func (StatusCode) IsServerError ΒΆ added in v1.0.47
func (s StatusCode) IsServerError() bool
IsServerError returns true if the status code indicates a server error [500, β].
func (StatusCode) IsSuccess ΒΆ added in v1.0.47
func (s StatusCode) IsSuccess() bool
IsSuccess returns true if the status code indicates a successful response [200, 300].
func (StatusCode) Text ΒΆ added in v1.0.47
func (s StatusCode) Text() string
Text returns the textual representation of the status code.
type StreamReader ΒΆ added in v1.0.177
StreamReader wraps bufio.Reader with Close support.
func (*StreamReader) Close ΒΆ added in v1.0.177
func (s *StreamReader) Close() error
Close closes the underlying body.
type TLSData ΒΆ added in v1.0.100
type TLSData struct {
CommonName []string // List of common names associated with the certificate.
DNSNames []string // List of DNS names associated with the certificate.
Emails []string // List of email addresses associated with the certificate.
IssuerCommonName []string // List of common names of the certificate issuer.
IssuerOrg []string // List of organizations of the certificate issuer.
Organization []string // List of organizations associated with the certificate.
ExtensionServerName string // Server name extension of the TLS certificate.
FingerprintSHA256 string // SHA-256 fingerprint of the certificate.
FingerprintSHA256OpenSSL string // SHA-256 fingerprint compatible with OpenSSL.
TLSVersion string // TLS version used.
}
TLSData represents information about a TLS certificate.
type TransportAdapter ΒΆ added in v1.0.100
type TransportAdapter struct {
// contains filtered or unexported fields
}
TransportAdapter adapts surf.Client to net/http.RoundTripper It uses the full surf pipeline including middleware
func (*TransportAdapter) CloseIdleConnections ΒΆ added in v1.0.100
func (s *TransportAdapter) CloseIdleConnections()
Source Files
ΒΆ
- adapter.go
- body.go
- builder.go
- client.go
- cookies.go
- debug.go
- defaults.go
- dnsovertls.go
- errors.go
- headers.go
- http2s.go
- http3s.go
- impersonate.go
- impersonate_os.go
- ja.go
- ja_roundtripper.go
- middleware.go
- middleware_client.go
- middleware_request.go
- middleware_response.go
- multipart.go
- pools.go
- request.go
- response.go
- status.go
- tls.go
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
async/async_get
command
|
|
|
async/async_get_context
command
|
|
|
async/async_get_std
command
|
|
|
auth/basic_auth
command
|
|
|
auth/bearer_basic
command
|
|
|
cache/body_cache
command
|
|
|
cache/cache
command
|
|
|
compression
command
|
|
|
context
command
|
|
|
cookies
command
|
|
|
custom/custom_client
command
|
|
|
custom/custom_tls_certificate
command
|
|
|
custom/custom_transport
command
|
|
|
debug
command
|
|
|
dns/custom_dns
command
|
|
|
dns/dns_over_tls
command
|
|
|
download/download_file
command
|
|
|
download/download_file_async
command
|
|
|
download/download_file_async_std
command
|
|
|
file_upload
command
|
|
|
headers/content_type
command
|
|
|
headers/headers
command
|
|
|
headers/headers_ordered
command
|
|
|
http/get
command
|
|
|
http/h2c
command
|
|
|
http/head
command
|
|
|
http/http1
command
|
|
|
http/http2
command
|
|
|
http/http3
command
|
|
|
impersonate/impersonate
command
|
|
|
impersonate/impersonate_async
command
|
|
|
impersonate/impersonate_custom
command
|
|
|
impersonate/impersonate_session
command
|
|
|
ja_hello/ja_hello_id
command
|
|
|
ja_hello/ja_hello_spec
command
|
|
|
keep_alive
command
|
|
|
limiter
command
|
|
|
md5
command
|
|
|
middleware
command
|
|
|
multipart
command
|
|
|
network
command
|
|
|
no_redirect
command
|
|
|
post
command
|
|
|
post/post_stream
command
|
|
|
proxy/rotating
command
|
|
|
proxy/simple
command
|
|
|
raw
command
|
|
|
redirect
command
|
|
|
remote_address
command
|
|
|
retry
command
|
|
|
session
command
|
|
|
split_request
command
|
|
|
sse
command
|
|
|
std/std
command
|
|
|
std/std_cookies
command
|
|
|
stream
command
|
|
|
timeout
command
|
|
|
tls
command
|
|
|
unix_socket
command
|
|
|
user_agent
command
|
|
|
utf8
command
|
|
|
internal
|
|
|
specclone
Package specclone provides deep cloning functionality for uTLS ClientHelloSpec structures.
|
Package specclone provides deep cloning functionality for uTLS ClientHelloSpec structures. |
|
pkg
|
|
|
quicconn
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn.
|
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn. |
|
profiles
|
|