Skip to main content

Module connection

Module connection 

Source
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, and upgrade directives
  • 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§

ConnectionInfo
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.