{"modulePath":"github.com/Method-Security/webscan","version":"v0.41.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package headless\n\n## Functions\n\n```go\nfunc IsTransientHeadlessError(err error) bool\n```\nIsTransientHeadlessError returns true for browser/network failures worth retrying with a fresh page or, when owned by this requester, a fresh browser.\n\n## Types\n\n```go\ntype NetworkHeaderCapture struct {\n\tHeaders map[string][]string\n\tURL     string\n\t// contains filtered or unexported fields\n}\n```\nNetworkHeaderCapture stores captured response headers\n\n```go\nfunc NewNetworkHeaderCapture() *NetworkHeaderCapture\n```\nNewNetworkHeaderCapture creates a new header capture instance\n\n```go\nfunc (n *NetworkHeaderCapture) GetHeaders() map[string][]string\n```\nGetHeaders safely gets headers\n\n```go\nfunc (n *NetworkHeaderCapture) SetHeaders(headers map[string][]string)\n```\nSetHeaders safely sets headers\n\n```go\ntype PageMetadata struct {\n\tHtmlTitle string\n}\n```\nPageMetadata carries headless-capture metadata that is not part of the wire HttpResponse but is useful to downstream callers (e.g. the \\\u003ctitle\u003e tag).\n\n```go\ntype Requester struct {\n\tBrowser                    *rod.Browser\n\tPathToBrowser              *string\n\tTimeoutSeconds             int\n\tMinDOMStabalizeTimeSeconds int\n\tHttpProxy                  string\n\tSocksProxy                 string\n\t// contains filtered or unexported fields\n}\n```\nRequester manages a headless browser instance and configuration for making requests.\n\n```go\nfunc NewRequester(timeout int, config *common.HeadlessRequestConfig) *Requester\n```\nNewRequester creates a new Requester with the given timeout and headless configuration.\n\n```go\nfunc NewRequesterWithClient(client *cdp.Client, timeout int, minDOMStabalizeTime int) (*Requester, error)\n```\nNewRequesterWithClient creates a new Requester using an existing rod cdp.Client.\n\n```go\nfunc NewRequesterwithBrowser(timeout int, config *common.HeadlessRequestConfig) *Requester\n```\nNewRequesterwithBrowser creates a new Requester with the given timeout and headless configuration.\n\n```go\nfunc (b *Requester) InitializeBrowser(ctx context.Context) error\n```\nInitializeBrowser 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/.\n\n```go\nfunc (b *Requester) ResetOwnedBrowser(ctx context.Context, reason string)\n```\nResetOwnedBrowser 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.\n\n```go\nfunc (b *Requester) SendRequest(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, error)\n```\nSendRequest navigates to a URL using the headless browser and captures the response\n\n```go\nfunc (b *Requester) SendRequestWithMetadata(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, PageMetadata, error)\n```\nSendRequestWithMetadata performs one headless navigation and returns page metadata without paying the screenshot capture cost.\n\n```go\nfunc (b *Requester) SendRequestWithScreenshot(ctx context.Context, config common.SendHttpRequestConfig) (common.HttpRequestResponse, []byte, PageMetadata, error)\n```\nSendRequestWithScreenshot 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. \\\u003ctitle\u003e) that are not part of the HttpResponse contract.\n\n```go\nfunc (b *Requester) SetProxyConfig(httpProxy, socksProxy string)\n```\nSetProxyConfig stores launch-scoped proxy configuration for browser instances created by this requester. HTTP takes precedence when both proxies are set.\n\n```go\nfunc (b *Requester) SetProxyConfigFromRequest(config common.SendHttpRequestConfig)\n```\nSetProxyConfigFromRequest stores proxy configuration from a request config.\n\n","path":"github.com/Method-Security/webscan/utils/request/headless","name":"headless","synopsis":"","isRedistributable":true}
