Documentation
¶
Overview ¶
Package client provides a high-level HTTP client with TLS fingerprint spoofing. It wraps the transport package with a convenient API for making HTTP requests that mimic real browser TLS fingerprints.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) DoRequest(ctx context.Context, req *transport.Request) (*transport.Response, error)
- func (c *Client) Get(ctx context.Context, url string) (*http.Response, error)
- func (c *Client) Jar() *cookie.Jar
- func (c *Client) Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
- func (c *Client) Profile() *profile.BrowserProfile
- func (c *Client) Stats() Stats
- func (c *Client) Transport() *transport.Transport
- type Config
- type Option
- func WithCookieJar(jar *cookie.Jar) Option
- func WithDNSCache(ttl time.Duration) Option
- func WithHTTP1() Option
- func WithHTTP3() Option
- func WithHTTPProxy(proxy string) Option
- func WithHeaderOrder(order []string) Option
- func WithIdleTimeout(d time.Duration) Option
- func WithInsecureSkipVerify() Option
- func WithLogger(logger *log.Logger) Option
- func WithMaxConnsPerHost(n int) Option
- func WithMaxRedirects(n int) Option
- func WithNoCookies() Option
- func WithNoRedirects() Option
- func WithProfile(p *profile.BrowserProfile) Option
- func WithPseudoHeaderOrder(order []string) Option
- func WithSOCKS5Proxy(proxy string) Option
- func WithTimeout(d time.Duration) Option
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a high-level HTTP client with TLS fingerprint spoofing.
func Chrome143Client ¶
Chrome143Client creates a client configured for Chrome 143.
func Firefox146Client ¶
Firefox146Client creates a client configured for Firefox 146.
func Safari261Client ¶
Safari261Client creates a client configured for Safari 26.1.
func (*Client) DoRequest ¶
func (c *Client) DoRequest(ctx context.Context, req *transport.Request) (*transport.Response, error)
DoRequest executes a request using the transport's native Request type.
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error)
Post performs a POST request.
func (*Client) Profile ¶
func (c *Client) Profile() *profile.BrowserProfile
Profile returns the client's browser profile.
type Config ¶
type Config struct {
Profile *profile.BrowserProfile
MaxConnsPerHost int
IdleTimeout time.Duration
Timeout time.Duration
Proxy string // Proxy address in "host:port:user:pass" or "host:port" format
ProxyType tls.ProxyType // HTTP or SOCKS5
Jar *cookie.Jar // Cookie jar for automatic cookie management
DNSCache *dns.Cache // Optional DNS cache for faster repeated lookups
DisableCookies bool // When true, disables automatic cookie handling
InsecureSkipVerify bool // Skip TLS certificate verification (testing only)
ForceHTTP1 bool // Force HTTP/1.1 instead of HTTP/2 (higher throughput mode)
EnableHTTP3 bool // Enable HTTP/3 with auto-fallback to HTTP/2
MaxRedirects int // Maximum redirects to follow (0=disabled, -1=unlimited, default=10)
Logger *log.Logger // Optional logger for request/response logging
HeaderOrder []string // Default HTTP header order (overrides browser profile)
PseudoHeaderOrder []string // Default HTTP/2 pseudo-header order (overrides browser profile)
}
Config holds client configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for high-throughput use.
type Option ¶
type Option func(*Config)
Option is a function that configures the client.
func WithCookieJar ¶
WithCookieJar sets a custom cookie jar. If not set, a new jar is created automatically.
func WithDNSCache ¶
WithDNSCache enables DNS caching with the specified TTL. This reduces DNS lookup latency for repeated requests to the same hosts. If ttl is 0, defaults to 5 minutes.
func WithHTTP1 ¶
func WithHTTP1() Option
WithHTTP1 forces the client to use HTTP/1.1 instead of HTTP/2. This can provide higher throughput by using multiple parallel connections, but offers less control over TLS fingerprinting (no HTTP/2 settings/priorities). Use this for high-throughput scenarios where fingerprint precision is less critical.
func WithHTTP3 ¶
func WithHTTP3() Option
WithHTTP3 enables HTTP/3 (QUIC) with auto-fallback to HTTP/2. HTTP/3 provides lower latency through 0-RTT connection establishment and multiplexing without head-of-line blocking. Falls back to HTTP/2 if QUIC fails. QUIC transport parameters are configured from the browser profile's HTTP3Profile.
func WithHTTPProxy ¶
WithHTTPProxy sets an HTTP CONNECT proxy. Format: "host:port" or "host:port:user:pass"
func WithHeaderOrder ¶
WithHeaderOrder sets the default HTTP header order for all requests. This overrides the browser profile's header order. Headers should be specified in lowercase (e.g., "host", "user-agent", "accept").
func WithIdleTimeout ¶
WithIdleTimeout sets the idle connection timeout.
func WithInsecureSkipVerify ¶
func WithInsecureSkipVerify() Option
WithInsecureSkipVerify skips TLS certificate verification. WARNING: This should only be used for testing purposes.
func WithLogger ¶
WithLogger sets a logger for request/response logging. Use log.Console() for pretty terminal output, log.File() for JSON file logging, or log.Multi() for both.
func WithMaxConnsPerHost ¶
WithMaxConnsPerHost sets the maximum connections per host.
func WithMaxRedirects ¶
WithMaxRedirects sets the maximum number of redirects to follow. Set to 0 to disable redirect following, -1 for unlimited. Default is 10.
func WithNoRedirects ¶
func WithNoRedirects() Option
WithNoRedirects disables automatic redirect following.
func WithProfile ¶
func WithProfile(p *profile.BrowserProfile) Option
WithProfile sets the browser profile.
func WithPseudoHeaderOrder ¶
WithPseudoHeaderOrder sets the HTTP/2 pseudo-header order for all requests. This overrides the browser profile's pseudo-header order. Example: []string{":method", ":authority", ":scheme", ":path"}
func WithSOCKS5Proxy ¶
WithSOCKS5Proxy sets a SOCKS5 proxy. Format: "host:port" or "host:port:user:pass"