requests

package
v0.0.0-...-3dc1f91 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMethodNotFound = errors.New("HTTP method not found")

Functions

func HandleRequests

func HandleRequests(w io.Writer, cfg *RequestsMetaConfig) (map[string][]ResponseData, error)

func RenderTLSData

func RenderTLSData(w io.Writer, r *http.Response)

func TLSVersionName

func TLSVersionName(v uint16) string

Types

type Host

type Host struct {
	Name    string `mapstructure:"name"`
	URIList []URI  `mapstructure:"uriList"`
}

type RequestConfig

type RequestConfig struct {
	Name                      string          `mapstructure:"name"`
	ClientTimeout             int             `mapstructure:"clientTimeout"`
	UserAgent                 string          `mapstructure:"userAgent"`
	TransportOverrideURL      string          `mapstructure:"transportOverrideUrl"`
	EnableProxyProtocolV2     bool            `mapstructure:"enableProxyProtocolV2"`
	Insecure                  bool            `mapstructure:"insecure"`
	RequestDebug              bool            `mapstructure:"requestDebug"`
	RequestHeaders            []RequestHeader `mapstructure:"requestHeaders"`
	RequestMethod             string          `mapstructure:"requestMethod"`
	RequestBody               string          `mapstructure:"requestBody"`
	ResponseDebug             bool            `mapstructure:"responseDebug"`
	ResponseHeadersFilter     []string        `mapstructure:"responseHeadersFilter"`
	ResponseBodyMatchRegexp   string          `mapstructure:"responseBodyMatchRegexp"`
	PrintResponseBody         bool            `mapstructure:"printResponseBody"`
	PrintResponseHeaders      bool            `mapstructure:"printResponseHeaders"`
	PrintResponseCertificates bool            `mapstructure:"printResponseCertificates"`
	Hosts                     []Host          `mapstructure:"hosts"`
}

func (*RequestConfig) PrintRequestDebug

func (r *RequestConfig) PrintRequestDebug(w io.Writer, req *http.Request) error

func (*RequestConfig) PrintResponseDebug

func (r *RequestConfig) PrintResponseDebug(w io.Writer, resp *http.Response)

func (*RequestConfig) PrintTitle

func (r *RequestConfig) PrintTitle(isVerbose bool)

type RequestHTTPClient

type RequestHTTPClient struct {
	// contains filtered or unexported fields
}

func NewHTTPClientFromRequestConfig

func NewHTTPClientFromRequestConfig(r RequestConfig, serverName string, caPool *x509.CertPool) (*RequestHTTPClient, error)

func NewRequestHTTPClient

func NewRequestHTTPClient() *RequestHTTPClient

func (*RequestHTTPClient) SetCACertsPool

func (rc *RequestHTTPClient) SetCACertsPool(caPool *x509.CertPool) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetClientTimeout

func (rc *RequestHTTPClient) SetClientTimeout(timeout int) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetInsecureSkipVerify

func (rc *RequestHTTPClient) SetInsecureSkipVerify(isInsecure bool) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetMethod

func (rc *RequestHTTPClient) SetMethod(method string) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetProxyProtocolHeader

func (rc *RequestHTTPClient) SetProxyProtocolHeader(header proxyproto.Header) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetProxyProtocolV2

func (rc *RequestHTTPClient) SetProxyProtocolV2(enable bool) *RequestHTTPClient

func (*RequestHTTPClient) SetServerName

func (rc *RequestHTTPClient) SetServerName(serverName string) (*RequestHTTPClient, error)

func (*RequestHTTPClient) SetTransportOverride

func (rc *RequestHTTPClient) SetTransportOverride(transportURL string) (*RequestHTTPClient, error)

type RequestHeader

type RequestHeader struct {
	Key   string `mapstructure:"key"`
	Value string `mapstructure:"value"`
}

type RequestsMetaConfig

type RequestsMetaConfig struct {
	// TODO: can we remove the following
	// three lines and just embed an "options"
	// struct to take care of metadata?
	RequestDebug   bool
	RequestVerbose bool
	CACertsPool    *x509.CertPool
	Requests       []RequestConfig `mapstructure:"requests"`
}

func NewRequestsMetaConfig

func NewRequestsMetaConfig() (*RequestsMetaConfig, error)

func (*RequestsMetaConfig) PrintCmd

func (r *RequestsMetaConfig) PrintCmd(w io.Writer)

func (*RequestsMetaConfig) SetCaPoolFromFile

func (r *RequestsMetaConfig) SetCaPoolFromFile(filePath string, fileReader certinfo.Reader) error

func (*RequestsMetaConfig) SetCaPoolFromYAML

func (r *RequestsMetaConfig) SetCaPoolFromYAML(s string) error

func (*RequestsMetaConfig) SetDebug

func (r *RequestsMetaConfig) SetDebug(b bool) *RequestsMetaConfig

func (*RequestsMetaConfig) SetRequests

func (r *RequestsMetaConfig) SetRequests(requests []RequestConfig) *RequestsMetaConfig

func (*RequestsMetaConfig) SetVerbose

func (r *RequestsMetaConfig) SetVerbose(b bool) *RequestsMetaConfig

type ResponseData

type ResponseData struct {
	Request                   RequestConfig
	TransportAddress          string
	URL                       string
	ResponseBody              string
	ResponseBodyRegexpMatched bool
	Response                  *http.Response
	Error                     error
}

func (*ResponseData) ImportResponseBody

func (rd *ResponseData) ImportResponseBody()

func (ResponseData) PrintResponseData

func (rd ResponseData) PrintResponseData(isVerbose bool)

type ResponseHeader

type ResponseHeader string

func (ResponseHeader) String

func (h ResponseHeader) String() string

type URI

type URI string

func (URI) Parse

func (u URI) Parse() bool

Jump to

Keyboard shortcuts

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