browserheaders

package
v0.111.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func ApplyRandom

func ApplyRandom(h http.Header)

ApplyRandom is shorthand for Random().Apply(h).

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).

func Random

func Random() Persona

Random returns a random Persona from the pool. Safe for concurrent use; uses the default math/rand source.

func (Persona) Apply

func (p Persona) Apply(h http.Header)

Apply writes the persona's headers into h, replacing any existing values for these keys.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL