Expand description
§use-header
Small HTTP header utilities for RustUse.
§Experimental
use-header is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.
§Example
use use_header::{get_header, parse_headers};
let headers = parse_headers("Content-Type: text/plain\nX-Trace: abc123");
assert_eq!(get_header(&headers, "content-type").as_deref(), Some("text/plain"));§Scope
- Header-name normalization and validation.
- Small helpers for parsing plain-text header blocks.
- Mutable helpers for setting and removing header values.
§Non-goals
- Full HTTP parsing.
- HTTP/2 or HTTP/3 frame handling.
- Client or server implementations.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Header
- A simple header name-value pair.
Functions§
- get_
header - Returns the first matching header value, compared case-insensitively.
- has_
header - Returns
truewhen the header list contains the requested name. - is_
valid_ header_ name - Returns
truewhen the input is a valid HTTP field name. - normalize_
header_ name - Normalizes a header name to lowercase ASCII.
- parse_
header_ line - Parses a single
Name: Valueheader line. - parse_
headers - Parses multiple header lines separated by newlines.
- remove_
header - Removes every header whose name matches case-insensitively.
- set_
header - Sets or replaces a header value.