request

package
v0.0.256 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBodyFromBytes added in v0.0.141

func CreateBodyFromBytes(contentType string, bodyData []byte) *common.Body

CreateBodyFromBytes creates a Body struct based on content type and body data as bytes

func CreateBodyFromDetectedBytes added in v0.0.245

func CreateBodyFromDetectedBytes(bodyData []byte) *common.Body

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

func DetectContentTypeFromBytes(bodyData []byte) string

DetectContentTypeFromBytes classifies body bytes using Go's content sniffing.

func FlattenHeaders added in v0.0.246

func FlattenHeaders(headers map[string][]string) map[string]string

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 GetHeaderValueFromHeaderMap

func GetHeaderValueFromHeaderMap(headers map[string][]string, name string) *string

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

func GetResponseBodyStringFromBodyStruct(body *common.Body) *string

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 IsDetectedBinaryBody added in v0.0.245

func IsDetectedBinaryBody(bodyData []byte) bool

IsDetectedBinaryBody reports whether body bytes classify the same way STANDARD would classify a binary response when no Content-Type header is available.

func ParseFormDataPairs added in v0.0.246

func ParseFormDataPairs(pairs []string) map[string]string

ParseFormDataPairs converts a slice of "key=value" strings (as supplied via a repeated --form-data CLI flag) into a map[string]string. Pairs that do not contain an equals sign are silently ignored. Leading and trailing whitespace is trimmed from both the key and the value. Returns nil when pairs is empty.

func ParseHeaderPairs added in v0.0.246

func ParseHeaderPairs(pairs []string) map[string]string

ParseHeaderPairs converts a slice of "Name: Value" strings (as supplied via a repeated --header CLI flag) into a map[string]string. Pairs that do not contain a colon are silently ignored. Leading and trailing whitespace is trimmed from both the name and the value. Returns nil when pairs is empty.

func RemoveScheme added in v0.0.93

func RemoveScheme(url string) string

RemoveScheme removes http:// or https:// from the beginning of a string

func SplitTargetURL

func SplitTargetURL(target string) (string, string, map[string]string, error)

SplitTargetURL splits a target URL and standardizes it into its base URL, path, and query parameter components.

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

Jump to

Keyboard shortcuts

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