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

headless

package
v0.0.270 Latest Latest
Warning

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

Go to latest
Published: Jun 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 Requester

type Requester struct {
	Browser                    *rod.Browser
	PathToBrowser              *string
	TimeoutSeconds             int
	MinDOMStabalizeTimeSeconds int
	// 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) SendRequestWithScreenshot added in v0.0.258

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

SendRequestWithScreenshot performs one headless navigation and captures both the HTTP response artifact and a screenshot from the same stabilized page.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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