Documentation
¶
Index ¶
- func ApplyProxySettings(ctx context.Context, config *common.SendHttpRequestConfig)
- func BuildAuthHeaders(headers map[string]string, cookies map[string]string) map[string][]string
- func CreateBodyFromBytes(contentType string, bodyData []byte) *common.Body
- func CreateBodyFromDetectedBytes(bodyData []byte) *common.Body
- func CreateHTTPResponse(statusCode int, redirectChain []string, headers map[string][]string, ...) common.HttpResponse
- func CreateHTTPResponseFromBytes(statusCode int, redirectChain []string, headers map[string][]string, ...) common.HttpResponse
- func DetectContentTypeFromBytes(bodyData []byte) string
- func FlattenHeaders(headers map[string][]string) map[string]string
- func GetContentTypeFromHeaderMap(headers map[string][]string) string
- func GetHeaderValueFromHeaderMap(headers map[string][]string, name string) *string
- func GetResponseBodyStringFromBodyStruct(body *common.Body) *string
- func GetUserAgentFlag(cmd *cobra.Command) (common.UserAgentPreset, error)
- func HasProxyConfig(config common.SendHttpRequestConfig) bool
- func IsDetectedBinaryBody(bodyData []byte) bool
- func JoinPath(basePath, childPath string) string
- func NormalizeHeaders(headers map[string][]string) map[string][]string
- func NormalizeTargetPath(path string) string
- func ParseCookiePairs(pairs []string) (map[string]string, error)
- func ParseFormDataPairs(pairs []string) (map[string]string, error)
- func ParseHeaderPairs(pairs []string) (map[string]string, error)
- func RemoveScheme(url string) string
- func SplitTargetURL(target string) (string, string, map[string]string, error)
- func UnwrapURLError(err error) error
- func ValidateUserAgentWithRequestMethod(userAgent common.UserAgentPreset, requestMethod common.RequestMethod, ...) error
- type MethodFlagData
- type TransportErrorCategory
- type TransportErrorDetail
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyProxySettings ¶ added in v0.0.283
func ApplyProxySettings(ctx context.Context, config *common.SendHttpRequestConfig)
ApplyProxySettings extracts proxy configuration from context and applies it to the request config
func BuildAuthHeaders ¶ added in v0.0.263
BuildAuthHeaders merges explicit request headers and cookies into a single multi-value header map suitable for HttpRequestParams. Cookies are folded into a single "Cookie" header so the standard transport forwards them; the headless transport additionally seeds the cookie jar from the same cookie map. Returns nil when neither headers nor cookies are supplied.
func CreateBodyFromBytes ¶ added in v0.0.141
CreateBodyFromBytes creates a Body struct based on content type and body data as bytes
func CreateBodyFromDetectedBytes ¶ added in v0.0.245
CreateBodyFromDetectedBytes classifies body bytes using Go's content sniffing.
func CreateHTTPResponse ¶
func CreateHTTPResponse(statusCode int, redirectChain []string, headers map[string][]string, responseBody string) common.HttpResponse
CreateHTTPResponse creates an HttpResponse struct from HttpResponse data (string version) This is a compatibility wrapper that converts string to bytes
func CreateHTTPResponseFromBytes ¶ added in v0.0.141
func CreateHTTPResponseFromBytes(statusCode int, redirectChain []string, headers map[string][]string, responseBody []byte) common.HttpResponse
CreateHTTPResponseFromBytes creates an HttpResponse struct from HttpResponse data using byte array
func DetectContentTypeFromBytes ¶ added in v0.0.245
DetectContentTypeFromBytes classifies body bytes using Go's content sniffing.
func FlattenHeaders ¶ added in v0.0.246
FlattenHeaders converts a multi-value header map (map[string][]string) into a single-value header map (map[string]string) by joining multiple values with a comma. This is the format expected by SendHTTPRequest. Ranging over a nil map is safe in Go so the caller does not need to nil-check before calling.
func GetContentTypeFromHeaderMap ¶ added in v0.0.259
func GetHeaderValueFromHeaderMap ¶
GetHeaderValueFromHeaderMap extracts a single header value from response header map. Returns the first value found for the given header name, or nil if not found.
func GetResponseBodyStringFromBodyStruct ¶
GetResponseBodyStringFromBodyStruct extracts string content from a Body struct
func GetUserAgentFlag ¶ added in v0.0.242
func GetUserAgentFlag(cmd *cobra.Command) (common.UserAgentPreset, error)
GetUserAgentFlag extracts and validates the user-agent flag from a cobra command. Returns UserAgentPresetRandom if the flag is not registered on this command.
func HasProxyConfig ¶ added in v0.2.0
func HasProxyConfig(config common.SendHttpRequestConfig) bool
HasProxyConfig reports whether a request is configured to use a local proxy.
func IsDetectedBinaryBody ¶ added in v0.0.245
IsDetectedBinaryBody reports whether body bytes classify the same way STANDARD would classify a binary response when no Content-Type header is available.
func JoinPath ¶ added in v0.20.0
JoinPath joins a base path and a child path with exactly one separator, preserving the child's trailing slash.
func NormalizeHeaders ¶ added in v0.0.271
NormalizeHeaders trims and drops empty response header values so serialized header maps always conform to map<string, list<string>> without null values.
func NormalizeTargetPath ¶ added in v0.20.0
NormalizeTargetPath collapses the authority root to "" per RFC 3986 6.2.3 and leaves every other path alone. A trailing slash on a non-empty path is part of the request, not noise.
func ParseCookiePairs ¶ added in v0.0.267
ParseCookiePairs converts a slice of "name=value" strings (as supplied via a repeated --cookie CLI flag) into a map[string]string. Each value must contain an equals sign; pairs that do not are returned as an error so the operator learns their cookie was malformed instead of having it silently dropped. Leading and trailing whitespace is trimmed from both the name and the value. Returns (nil, nil) when pairs is empty.
func ParseFormDataPairs ¶ added in v0.0.246
ParseFormDataPairs converts a slice of "key=value" strings (as supplied via a repeated --form-data CLI flag) into a map[string]string. Each value must contain an equals sign; pairs that do not are returned as an error so the operator learns their value was malformed instead of having it silently dropped. Leading and trailing whitespace is trimmed from both the key and the value. Returns (nil, nil) when pairs is empty.
func ParseHeaderPairs ¶ added in v0.0.246
ParseHeaderPairs converts a slice of "Name: Value" strings (as supplied via a repeated --header CLI flag) into a map[string]string. Each value must contain a colon; pairs that do not are returned as an error so the operator learns their header was malformed instead of having it silently dropped. Leading and trailing whitespace is trimmed from both the name and the value.
Repeated header names are case-insensitively merged into a single comma- joined value per RFC 7230 §3.2.2 ("a recipient MAY combine multiple header fields with the same field name into one ... by appending each subsequent field value to the combined field value in order, separated by a comma"). The first-seen casing of the header name is preserved. This makes repeated `--header "Accept: application/json"` + `--header "Accept: text/html"` emit `Accept: application/json, text/html` rather than dropping the second value.
Returns (nil, nil) when pairs is empty.
func RemoveScheme ¶ added in v0.0.93
RemoveScheme removes http:// or https:// from the beginning of a string
func SplitTargetURL ¶
SplitTargetURL splits a target URL and standardizes it into its base URL, path, and query parameter components.
func UnwrapURLError ¶ added in v0.0.263
UnwrapURLError returns the inner error of a *url.Error, which strips the repeated `Method "url":` prefix when the caller already logs the URL separately. The original error is returned when it is not a *url.Error.
func ValidateUserAgentWithRequestMethod ¶ added in v0.0.242
func ValidateUserAgentWithRequestMethod(userAgent common.UserAgentPreset, requestMethod common.RequestMethod, explicit bool) error
ValidateUserAgentWithRequestMethod returns an error if the user explicitly supplied --user-agent in a way the request method cannot honor. `explicit` must be true only when the user actually typed the flag on the command line (typically cmd.Flags().Changed("user-agent")); a missing flag is never an error and uses the request method's default UA.
Headless and browserbase modes apply CHROME/FIREFOX/SAFARI/EDGE via CDP, but reject RANDOM because randomizing the UA string while every other browser-introspectable signal still says Chromium creates an obvious fingerprint mismatch. Operators who want Chrome's real UA should simply omit the flag.
Types ¶
type MethodFlagData ¶ added in v0.0.93
type MethodFlagData struct {
RequestMethodEnum common.RequestMethod
HeadlessConfig *common.HeadlessRequestConfig
BrowserbaseConfig *common.BrowserbaseRequestConfig
BrowserbaseSecrets *common.BrowserbaseRequestSecrets
}
MethodFlagData holds all the configuration related to request methods
func GetRequestMethodFlags ¶ added in v0.0.93
func GetRequestMethodFlags(cmd *cobra.Command) (*MethodFlagData, error)
GetRequestMethodFlags extracts and validates all request method related configuration from a cobra command
type TransportErrorCategory ¶ added in v0.0.263
type TransportErrorCategory string
TransportErrorCategory is a stable, coarse classification of an HTTP attempt that never produced a response. Because there is no HTTP status code in that case, this category is the closest thing to an "error code" an operator can filter/triage on, which is exactly what is missing when a request fails behind a restrictive firewall and the only artifact is an opaque error.
const ( TransportErrorDNS TransportErrorCategory = "dns_resolution_failed" TransportErrorConnRefused TransportErrorCategory = "connection_refused" TransportErrorConnReset TransportErrorCategory = "connection_reset" TransportErrorTimeout TransportErrorCategory = "timeout" TransportErrorTLS TransportErrorCategory = "tls_error" TransportErrorNoRouteToHost TransportErrorCategory = "no_route_to_host" TransportErrorNetworkDown TransportErrorCategory = "network_unreachable" TransportErrorCanceled TransportErrorCategory = "canceled" TransportErrorTransport TransportErrorCategory = "transport_error" )
type TransportErrorDetail ¶ added in v0.0.263
type TransportErrorDetail struct {
Category TransportErrorCategory
Cause string
Op string
Network string
Address string
}
TransportErrorDetail is a structured, operator-facing description of a failed transport attempt. Cause is always the fully unwrapped error string (never the reflected struct), and the remaining fields name the layer that failed so a firewall/DNS/TLS problem can be told apart at a glance.
func ClassifyTransportError ¶ added in v0.0.263
func ClassifyTransportError(err error) TransportErrorDetail
ClassifyTransportError unwraps a Go HTTP client error (typically a *url.Error wrapping *net.OpError / *net.DNSError / x509 / tls / syscall errors) into a stable category plus the underlying cause and the network layer that failed. It exists so that a web request which never reaches the target surfaces *why* (DNS, refused, reset, no route, TLS, timeout) instead of an opaque struct dump — the common failure shape when egress is blocked by a customer firewall.
func (TransportErrorDetail) String ¶ added in v0.0.263
func (d TransportErrorDetail) String() string
String renders the detail as a single human-readable line suitable for a log param, a returned error, or a signal error entry.