Documentation ¶
Overview ¶
Package response executes HTTP requests and handles the response.
Index ¶
- Constants
- func AddTransportFlags(fs *pflag.FlagSet, opts *TransportOptions)
- func Mark(in <-chan Response, filters []Filter) <-chan Response
- func NewTransport(opts TransportOptions, concurrentRequests int) (*http.Transport, error)
- type Extracter
- type Filter
- type FilterAcceptPattern
- type FilterRejectPattern
- type FilterSize
- type FilterStatusCode
- type InvalidRequest
- type Response
- func (r *Response) ExtractBody(targets []*regexp.Regexp)
- func (r *Response) ExtractBodyCommand(ctx context.Context, cmds [][]string) (err error)
- func (r *Response) ExtractHeader(res *http.Response, targets []*regexp.Regexp) error
- func (r *Response) ReadBody(res *http.Response, maxBodySize int, decompress bool) (finalError error)
- func (r Response) String() string
- type Runner
- type TextStats
- type TransportOptions
Constants ¶
const ( // DefaultMaxBodySize is the default size for peeking at the body to extract strings via regexp. DefaultMaxBodySize = 5 * 1024 * 1024 // DefaultConnectTimeout limits how long the TCP connection setup can take. DefaultConnectTimeout = 30 * time.Second // DefaultTLSHandshakeTimeout limits the time until a TLS connection must be established. DefaultTLSHandshakeTimeout = 10 * time.Second // DefaultResponseHeaderTimeout limits the time until the first HTTP // response header must have been received. DefaultResponseHeaderTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddTransportFlags ¶ added in v0.8.0
func AddTransportFlags(fs *pflag.FlagSet, opts *TransportOptions)
func Mark ¶
Mark runs all responses through filters and sets the Hide attribute if a filter matches. Filtering is done in a separate goroutine, which terminates when the input channel is closed.
func NewTransport ¶
func NewTransport(opts TransportOptions, concurrentRequests int) (*http.Transport, error)
NewTransport creates a new shared transport for clients to use.
Types ¶
type Extracter ¶
Extracter collects data from interesting (non-hidden) responses.
func (*Extracter) Run ¶
Run extracts data from the body of a response by running external commands and feeding them the response body. Commands used to extract data are only run for non-hidden responses, since this is expensive.
The values that were used to produce the request are passed in the environment variable $MONSOON_VALUE (for the first one) and $MONSOON_VALUE1 to $MONSOON_VALUEN if several values were used.
type FilterAcceptPattern ¶
FilterAcceptPattern filters responses based on patterns (header and body are matched).
func (FilterAcceptPattern) Reject ¶
func (f FilterAcceptPattern) Reject(res Response) bool
Reject decides if r is to be printed.
type FilterRejectPattern ¶
FilterRejectPattern filters responses based on patterns (header and body are matched).
func (FilterRejectPattern) Reject ¶
func (f FilterRejectPattern) Reject(res Response) bool
Reject decides if r is to be printed.
type FilterSize ¶
type FilterSize struct {
// contains filtered or unexported fields
}
FilterSize hides responses based on a size.
func NewFilterSize ¶
func NewFilterSize(headerBytes, bodyBytes []string) (FilterSize, error)
NewFilterSize returns an initialized FilterSize.
func (FilterSize) Reject ¶
func (f FilterSize) Reject(r Response) bool
Reject decides if r is to be printed.
type FilterStatusCode ¶
type FilterStatusCode struct {
// contains filtered or unexported fields
}
FilterStatusCode hides responses based on the HTTP status code.
func NewFilterStatusCode ¶
func NewFilterStatusCode(rejects, accepts []string) (FilterStatusCode, error)
NewFilterStatusCode returns a filter based on HTTP status code.
func (FilterStatusCode) Reject ¶
func (f FilterStatusCode) Reject(r Response) bool
Reject decides if r is to be printed.
type InvalidRequest ¶ added in v0.7.0
type InvalidRequest struct {
Err error
}
func (InvalidRequest) Error ¶ added in v0.7.0
func (ir InvalidRequest) Error() string
type Response ¶
type Response struct { Values []string URL string Error error Duration time.Duration Header, BodyStats TextStats Extract []string ExtractError error HTTPResponse *http.Response Body []byte RawHeader []byte Decompressed bool Hide bool // can be set by a filter, response should not be displayed }
Response is an HTTP response.
func (*Response) ExtractBody ¶
ExtractBody extracts data from the HTTP response body.
func (*Response) ExtractBodyCommand ¶
ExtractBodyCommand extracts data from the HTTP response body by running an external command.
func (*Response) ExtractHeader ¶
ExtractHeader extracts data from an HTTP header. This fills r.Header.
type Runner ¶
type Runner struct { Template *request.Request MaxBodySize int Extract []*regexp.Regexp Client *http.Client Transport *http.Transport DecompressResponseBody bool PreserveRequestBody bool // contains filtered or unexported fields }
Runner executes HTTP requests.
type TextStats ¶
type TextStats struct { Bytes int `json:"bytes"` Words int `json:"words"` Lines int `json:"lines"` }
TextStats reports statistics about some text.
type TransportOptions ¶ added in v0.8.0
type TransportOptions struct { SkipCertificateVerification bool EnableInsecureCiphersAndTLSVersions bool TLSClientCertKeyFilename string DisableHTTP2 bool Network string ConnectTimeout time.Duration TLSHandshakeTimeout time.Duration ResponseHeaderTimeout time.Duration }
func (TransportOptions) Valid ¶ added in v0.8.0
func (t TransportOptions) Valid() error