Documentation
¶
Index ¶
- func IsTransientHeadlessError(err error) bool
- type NetworkHeaderCapture
- type Requester
- func (b *Requester) InitializeBrowser(ctx context.Context) error
- func (b *Requester) ResetOwnedBrowser(ctx context.Context, reason string)
- func (b *Requester) SendRequest(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, error)
- func (b *Requester) SendRequestWithScreenshot(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, []byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTransientHeadlessError ¶ added in v0.0.257
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 ¶
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
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 ¶
func (b *Requester) SendRequest(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, error)
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.