Documentation
¶
Overview ¶
Package browserheaders generates a coherent set of browser-typical HTTP request headers for outbound calls that need to evade trivial bot detection.
The fleet's canonical "I'm a bot, please rate-limit me" User-Agent (`ua.Build`) is appropriate for inbound APIs that want to be identified — but lethal for outbound calls to anti-bot endpoints like DuckDuckGo, Cloudflare-protected sites, etc.
Why "coherent set" ¶
Modern bot detectors (DDG, Cloudflare, Akamai, PerimeterX, DataDome) check that headers are internally consistent. Examples:
- Chrome's User-Agent → must come with Sec-Ch-Ua "Google Chrome"
- Firefox's User-Agent → must NOT send Sec-Ch-Ua
- Safari's User-Agent → must NOT send Sec-Ch-Ua
- Accept-Encoding should always include "br" on modern browsers
Mixing Chrome's UA with Firefox's Sec-Ch-Ua absence is a tell. So we rotate full personas (browser+OS+version), not individual fields.
Usage ¶
persona := browserheaders.Random() persona.Apply(req.Header) // or one-shot: browserheaders.ApplyRandom(req.Header)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Persona ¶
type Persona struct {
UserAgent string
Accept string
AcceptLanguage string
AcceptEncoding string
SecChUa string // empty if not a Chromium-family browser
SecChUaMobile string // ?0 (desktop) or ?1 (mobile)
SecChUaPlatform string // "macOS" / "Windows" / "Linux" / etc.
// Set Upgrade-Insecure-Requests: 1
UpgradeInsecure bool
// Set DNT: 1
DoNotTrack bool
}
Persona is one self-consistent browser identity.
func Personas ¶
func Personas() []Persona
Personas returns a copy of the internal persona list. Useful for tests and for callers that want to filter (e.g. desktop-only).