Skip to main content

Crate use_header

Crate use_header 

Source
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 true when the header list contains the requested name.
is_valid_header_name
Returns true when 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: Value header 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.