Documentation
¶
Index ¶
Constants ¶
const DefaultMaxBodyBuffer int64 = 4 * 1024 * 1024
DefaultMaxBodyBuffer is the default maximum body size that will be buffered in memory to enable retries (4 MiB).
Variables ¶
var DefaultRetryConfig = RetryConfig{ MaxAttempts: 3, BaseDelay: 300 * time.Millisecond, MaxDelay: 5 * time.Second, RetryOnCodes: []int{429, 500, 502, 503, 504}, MaxBodyBuffer: 0, }
DefaultRetryConfig provides a sensible default configuration for request retries.
Functions ¶
func GetLatestChrome ¶
func GetLatestChrome() profiles.ClientProfile
GetLatestChrome returns the most recent Chrome client profile available in the TLS client profiles map. It dynamically parses version numbers from profile keys, caches the result on the first call, and falls back to the default profile if no Chrome profiles are found.
func NewHttpClient ¶
func NewHttpClient(s ClientSettings) (*http.Client, error)
NewHttpClient returns a configured HTTP client initialized with TLS-evasion capabilities, header rotation, and automatic retries based on the provided settings.
Types ¶
type ClientSettings ¶
type ClientSettings struct {
MaxTimeoutSeconds int
TargetURL string
StrictSSL bool
NetMode NetworkMode
ProxyURI string
Retry RetryConfig
}
ClientSettings encapsulates the configuration parameters for initializing an HTTP client.
type NetworkMode ¶
type NetworkMode string
NetworkMode defines the IP protocol version preference for network connections.
const ( // NetworkModeAuto specifies that the client should automatically select the IP protocol version. NetworkModeAuto NetworkMode = "" // NetworkModeIPv4 restricts the client to IPv4 connections only. NetworkModeIPv4 NetworkMode = "ipv4" // NetworkModeIPv6 restricts the client to IPv6 connections only. NetworkModeIPv6 NetworkMode = "ipv6" )
type RetryConfig ¶
type RetryConfig struct {
// MaxAttempts is the maximum number of attempts (0 = no retry).
MaxAttempts int
// BaseDelay is the initial delay between attempts.
BaseDelay time.Duration
// MaxDelay is the delay ceiling.
MaxDelay time.Duration
// RetryOnCodes lists response status codes that trigger a retry.
RetryOnCodes []int
// MaxBodyBuffer is the maximum number of bytes buffered in memory to make
// a non-seekable request body replayable.
// 0 -> use DefaultMaxBodyBuffer
// -1 -> disable buffering entirely; requests with non-seekable bodies
// will be attempted only once.
MaxBodyBuffer int64
}
RetryConfig defines the policy for retrying failed HTTP requests.