Expand description
HTTP Connection header handling.
This module provides proper parsing and handling of the HTTP Connection header
per RFC 7230, including:
- Parsing comma-separated connection tokens
- Handling
close,keep-alive, andupgradedirectives - Extracting hop-by-hop header names for stripping
- HTTP version-aware default behavior
§Connection Header Semantics
The Connection header is a comma-separated list of tokens. Each token is either:
- A connection option (
close,keep-alive,upgrade) - The name of a hop-by-hop header field to be stripped when forwarding
§Example
ⓘ
use fastapi_http::connection::{ConnectionInfo, parse_connection_header};
let info = parse_connection_header(Some(b"keep-alive, X-Custom-Header"));
assert!(info.keep_alive);
assert!(info.hop_by_hop_headers.contains(&"x-custom-header".to_string()));Structs§
- Connection
Info - Parsed Connection header information.
Constants§
- STANDARD_
HOP_ BY_ HOP_ HEADERS - Standard hop-by-hop headers that should always be stripped when forwarding.
Functions§
- is_
standard_ hop_ by_ hop_ header - Check if a header name is a hop-by-hop header.
- parse_
connection_ header - Parses the Connection header from a request and returns connection info.
- should_
keep_ alive - Determines if a connection should be kept alive based on request headers and version.
- strip_
hop_ by_ hop_ headers - Strip hop-by-hop headers from a request.