Help us shape the future of Go! Take the 2026 Go Developer Survey

headless

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTransientHeadlessError added in v0.0.257

func IsTransientHeadlessError(err error) bool

IsTransientHeadlessError returns true for browser/network failures worth retrying with a fresh page or, when owned by this requester, a fresh browser.

Types

type NetworkHeaderCapture added in v0.0.112

type NetworkHeaderCapture struct {
	Headers map[string][]string
	// contains filtered or unexported fields
}

NetworkHeaderCapture stores captured response headers

func NewNetworkHeaderCapture added in v0.0.112

func NewNetworkHeaderCapture() *NetworkHeaderCapture

NewNetworkHeaderCapture creates a new header capture instance

func (*NetworkHeaderCapture) GetHeaders added in v0.0.112

func (n *NetworkHeaderCapture) GetHeaders() map[string][]string

GetHeaders safely gets headers

func (*NetworkHeaderCapture) SetHeaders added in v0.0.112

func (n *NetworkHeaderCapture) SetHeaders(headers map[string][]string)

SetHeaders safely sets headers

type PageMetadata added in v0.0.278

type PageMetadata struct {
	HtmlTitle string
}

PageMetadata carries headless-capture metadata that is not part of the wire HttpResponse but is useful to downstream callers (e.g. the <title> tag).

type Requester

type Requester struct {
	Browser                    *rod.Browser
	PathToBrowser              *string
	TimeoutSeconds             int
	MinDOMStabalizeTimeSeconds int
	HttpProxy                  string
	SocksProxy                 string
	// contains filtered or unexported fields
}

Requester manages a headless browser instance and configuration for making requests.

func NewRequester

func NewRequester(timeout int, config *common.HeadlessRequestConfig) *Requester

NewRequester creates a new Requester with the given timeout and headless configuration.

func NewRequesterWithClient

func NewRequesterWithClient(client *cdp.Client, timeout int, minDOMStabalizeTime int) (*Requester, error)

NewRequesterWithClient creates a new Requester using an existing rod cdp.Client.

func NewRequesterwithBrowser added in v0.0.112

func NewRequesterwithBrowser(timeout int, config *common.HeadlessRequestConfig) *Requester

NewRequesterwithBrowser creates a new Requester with the given timeout and headless configuration.

func (*Requester) InitializeBrowser

func (b *Requester) InitializeBrowser(ctx context.Context) error

InitializeBrowser starts a headless browser instance and establishes connection. If a browser path is specified and exists, it uses that binary. Otherwise it falls back to rod's auto-download, which fetches a compatible Chromium to ~/.cache/rod/browser/.

func (*Requester) ResetOwnedBrowser added in v0.0.257

func (b *Requester) ResetOwnedBrowser(ctx context.Context, reason string)

ResetOwnedBrowser closes a browser launched by this requester so the next operation can start from a fresh browser process. Caller-owned browsers and externally supplied CDP clients are left untouched.

func (*Requester) SendRequest

SendRequest navigates to a URL using the headless browser and captures the response

func (*Requester) SendRequestWithMetadata added in v0.2.0

SendRequestWithMetadata performs one headless navigation and returns page metadata without paying the screenshot capture cost.

func (*Requester) SendRequestWithScreenshot added in v0.0.258

func (b *Requester) SendRequestWithScreenshot(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, []byte, PageMetadata, error)

SendRequestWithScreenshot performs one headless navigation and captures both the HTTP response artifact and a screenshot from the same stabilized page. The returned PageMetadata carries fields harvested from the live DOM (e.g. <title>) that are not part of the HttpResponse contract.

func (*Requester) SetProxyConfig added in v0.0.283

func (b *Requester) SetProxyConfig(httpProxy, socksProxy string)

SetProxyConfig stores launch-scoped proxy configuration for browser instances created by this requester. HTTP takes precedence when both proxies are set.

func (*Requester) SetProxyConfigFromRequest added in v0.0.283

func (b *Requester) SetProxyConfigFromRequest(config common.SendHttpRequestConfig)

SetProxyConfigFromRequest stores proxy configuration from a request config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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