packages

http::headers

On this page

Header fields (RFC 9110): a case-insensitive multimap that keeps insertion order.

Structs

HeaderMapSource

pub struct HeaderMap

Header fields in order. Names are stored lowercase (lookups ignore case); a name may repeat. Like List, a HeaderMap is a handle: copies share the fields (clone for an independent map).

  • pub fn new() -> HeaderMap§

    Source
  • pub fn len(self) -> usize§

    Source

    Number of fields (each repeat counts).

  • pub fn is_empty(self) -> bool§

    Source
  • pub fn get(self, name: str) -> str | none§

    Source

    The first value of name.

  • pub fn get_all(self, name: str) -> List<str>§

    Source

    Every value of name, in order.

  • pub fn contains(self, name: str) -> bool§

    Source
  • pub fn append(self, name: str, value: str)§

    Source

    Add a field after the existing ones.

  • pub fn insert(self, name: str, value: str)§

    Source

    Replace every value of name with value.

  • pub fn remove(self, name: str) -> bool§

    Source

    Remove every value of name; whether there was one.

  • pub fn entries(self) -> List<(str, str)>§

    Source

    (name, value) pairs in order, names lowercase.

  • pub fn has_token(self, name: str, token: str) -> bool§

    Source

    Whether a comma-separated list header name contains token (ASCII case-insensitive): has_token("connection", "close").

  • pub fn validate(self) throws (HttpError)§

    Source

    Throws if a name is not a token or a value has CR, LF, NUL or another control character (except tab): what goes on the wire must not be able to inject fields.

Trait implementations 2
  • impl Clone for HeaderMap
  • impl Debug for HeaderMap

Functions

is_tokenSource

pub fn is_token(s: str) -> bool

A non-empty run of tchars.

is_field_valueSource

pub fn is_field_value(s: str) -> bool

A field value: visible ASCII, space, tab and obs-text, no leading or trailing whitespace.