Available on crate feature
http only.Expand description
Passive HTTP/1.x observer.
Bridges httparse’s
zero-copy parser into flowscope’s
SessionParser abstraction. Receives
bytes from the per-flow TCP stream, emits parsed
HttpRequest / HttpResponse events as
HttpMessage variants.
§Quick start
use flowscope::extract::FiveTuple;
use flowscope::http::{HttpMessage, HttpParser};
use flowscope::{FlowSessionDriver, SessionEvent, SessionParser, Timestamp};
let _driver = FlowSessionDriver::new(
FiveTuple::bidirectional(),
HttpParser::default(),
);For a callback-shaped interface, drive a SessionParser from
a consumer loop — Application events carry the parsed
HttpMessage directly:
for view in views() {
for ev in driver.track(view) {
if let SessionEvent::Application { message, .. } = ev {
match message {
HttpMessage::Request(r) => { /* handle request */ }
HttpMessage::Response(r) => { /* handle response */ }
}
}
}
}§Scope
- HTTP/1.0 and HTTP/1.1.
- Request line + headers + body via Content-Length.
- Pipelined requests on one connection.
- HTTP/2 / HTTP/3: out of scope.
- Chunked Transfer-Encoding: deferred.
§Convenience accessors
Every header accessor below skips the boilerplate of “iterate
the headers: Vec<(String, Vec<u8>)>, case-insensitive
compare, then from_utf8”. They cover the headers every
HTTP-monitor example reached for.
§HttpRequest
| Method | Returns | Equivalent |
|---|---|---|
host | Option<&str> | first Host header |
user_agent | Option<&str> | first User-Agent |
cookie | Option<&str> | first Cookie |
content_type | Option<&str> | Content-Type (new in 0.10) |
content_length | Option<u64> | parsed Content-Length (new in 0.10) |
referer | Option<&str> | Referer (new in 0.10) |
accept | Option<&str> | Accept (new in 0.10) |
header | Option<&[u8]> | first matching header (case-insensitive) |
headers_all | impl Iterator<Item = &[u8]> | every matching header |
§HttpResponse
| Method | Returns | Equivalent |
|---|---|---|
status_class | Option<u8> | status / 100 (new in 0.10) |
is_success | bool | 2xx (new in 0.10) |
is_redirect | bool | 3xx (new in 0.10) |
is_client_error | bool | 4xx (new in 0.10) |
is_server_error | bool | 5xx (new in 0.10) |
content_type | Option<&str> | Content-Type |
content_length | Option<u64> | parsed Content-Length |
set_cookie | impl Iterator<Item = &str> | every Set-Cookie header |
header | Option<&[u8]> | first matching header |
headers_all | impl Iterator<Item = &[u8]> | every matching header |
Structs§
- Http
Config - Configuration knobs for the HTTP parser.
- Http
Exchange - One HTTP request + response pair.
- Http
Exchange Parser SessionParserimpl that emits oneHttpExchangeper request/response pair.- Http
Parser - Per-flow HTTP/1.x parser. Holds independent state for the initiator (request) and responder (response) directions.
- Http
Request - Parsed HTTP/1.x request — start line + headers + body.
- Http
Response - Parsed HTTP/1.x response.
Enums§
- Http
Message - Unified message type emitted by
HttpParser. - Http
Outcome - Outcome of an observed HTTP exchange.
- Http
Version
Constants§
- PARSER_
KIND - Slug returned by
HttpParser’sparser_kind(). Use at match sites in place of a string literal so typos fail to resolve instead of silently miss. Available also asflowscope::parser_kinds::HTTP.