fakebrowser

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHeaders = map[string]string{
	"Accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8",
	"Accept-Language": "en-US,en;q=0.5",
	"Referer":         "https://duckduckgo.com/",
	"User-Agent":      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0",
}

DefaultHeaders defines the headers that will be injected into every outgoing request in order to simulate the appearance of a real web browser.

Not very sportsmanlike, but basically effective at letting us fetch page titles.

Functions

This section is empty.

Types

type Option

type Option func(*Transport)

Option customizes a Transport.

func WithHeaders

func WithHeaders(injectHeaders map[string]string) Option

WithHeaders overrides the default set of headers injected into each request.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport is an http.RoundTripper implementation that injects a set of headers into every outgoing request in order to fake the appearance of a real web browser making the request.

func New

func New(transport http.RoundTripper, opts ...Option) *Transport

New creates a new fake browswer transport.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction, after injecting a set of headers into the outgoing request.

Jump to

Keyboard shortcuts

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