requestinput

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
var ErrEmpty = errors.New("empty request input")

ErrEmpty is returned for input with no request text.

Functions

func DeclaresBody

func DeclaresBody(raw string) bool

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.

func Normalize

func Normalize(raw string) (parsed, send string)

Normalize returns the text to parse and the bytes to send for raw. See the package comment.

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.

func Parse

func Parse(ctx context.Context, raw string, opts Options) (Result, error)

Parse normalizes raw, parses it and settles its scheme.

Jump to

Keyboard shortcuts

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