Documentation
¶
Overview ¶
Package requestinput turns raw HTTP request text into the request to send, with one normalization and one scheme rule for every command that takes a request as text (scan-request, replay -i, fuzz -i):
- Normalize: leading whitespace is dropped; a request that declares no body (no Content-Length, no Transfer-Encoding) loses its trailing whitespace and gets exactly one header terminator, so text pasted with the final blank line stripped, or read from a line-trimming stdin, parses and sends. A body-bearing request keeps its bytes.
- Scheme: a target override (-t) pins scheme, host and port; otherwise an absolute request line, a Host on :80/:443, or a same-origin Origin or Referer settles it; failing those the target is probed (TCP connect, TLS handshake) unless the caller turns the probe off, and https is the default (requestscheme.Settle).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = errors.New("empty request input")
ErrEmpty is returned for input with no request text.
Functions ¶
func DeclaresBody ¶
DeclaresBody reports whether the header block of raw carries a Content-Length or Transfer-Encoding header. Only the header block is scanned, case-insensitively at the start of a line.
Types ¶
type Options ¶
type Options struct {
// Target is the -t override: the base URL whose scheme, host and port the
// request goes to. It pins the scheme (no probe).
Target string
// NoProbe keeps the inferred default instead of probing the target.
NoProbe bool
// Resolver replaces the scheme probe (tests). Nil = the real probe.
Resolver requestscheme.Resolver
// Admit, when set, is the caller's scope check. It is asked about the
// parsed target before the scheme probe could contact it, and again when
// the probe moved the target; its error ends Parse.
Admit func(target string) error
}
Options tune Parse.
type Result ¶
type Result struct {
// Request is the request to send, its URL settled.
Request *httpmsg.HttpRequestResponse
// Raw is the normalized request text, header terminator included: the
// bytes a raw sender writes.
Raw string
// Parsed is the text the parser read (Raw without a bodyless request's
// terminator), what requestscheme and a re-parse expect.
Parsed string
// SchemeSource says what settled the scheme (requestscheme.Source*).
SchemeSource string
// Scheme is the result of requestscheme.Settle, for callers that report
// how the scheme was chosen.
Scheme requestscheme.Result
}
Result is a parsed request.