Skip to main content

peek_http_input_with_options

Function peek_http_input_with_options 

pub async fn peek_http_input_with_options<PeekableInput>(
    input: PeekableInput,
    options: HttpPeekOptions,
) -> Result<(Option<HttpPeekVersion>, <PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>), Box<dyn Error + Send + Sync>>
where PeekableInput: PeekIoProvider, <PeekableInput as PeekIoProvider>::PeekIo: Unpin, <PeekableInput as PeekIoProvider>::PeekEgressIo: Unpin,
Available on crate feature net only.
Expand description

Detect HTTP using explicit options and return an input that replays every byte consumed during detection, on both sides.

HTTP/1.0 and HTTP/1.1 are accepted only after a complete request-line containing a valid method token, request target, HTTP/1.<digit> version, and line terminator has been read. An HTTP/0.9 simple-request is accepted as HTTP/1x after GET, a valid request target, and a line terminator. Matching lenient HTTP/1 parsers such as httparse, a bare LF is accepted as line terminator and empty lines before the request-line are skipped (they count toward HttpPeekConfig::max_http1_request_line_size). HTTP/2 is accepted only after its complete client preface, starting at the first byte.

On a BridgeIo the egress is judged by HttpPeekOptions::with_egress. A definitive non-HTTP prefix returns Ok((None, input)). A cutoff does the same, unless the PeekPolicy fails the peek.