Documentation
¶
Overview ¶
Package response executes HTTP requests and handles the response.
Index ¶
- Constants
- func Mark(in <-chan Response, filters []Filter) <-chan Response
- func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 bool, ...) (*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(cmds [][]string) (err error)
- func (r *Response) ExtractHeader(res *http.Response, targets []*regexp.Regexp) error
- func (r *Response) ReadBody(body io.Reader, maxBodySize int) (err error)
- func (r Response) String() string
- type Runner
- type TextStats
Constants ¶
const DefaultMaxBodySize = 5 * 1024 * 1024
DefaultMaxBodySize is the default size for peeking at the body to extract strings via regexp.
Variables ¶
This section is empty.
Functions ¶
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. Extraction is done in a separate goroutine, which terminates when the input channel is closed.
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 {
Item string
URL string
Error error
Duration time.Duration
Header, Body TextStats
Extract []string
HTTPResponse *http.Response
RawBody []byte
RawHeader []byte
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
// contains filtered or unexported fields
}
Runner executes HTTP requests.