Module header

HTTP header types

The module provides HeaderName, HeaderMap, and a number of types used for interacting with HeaderMap. These types allow representing both HTTP/1 and HTTP/2 headers.

HeaderName

The HeaderName type represents both standard header names as well as custom header names. The type handles the case insensitive nature of header names and is used as the key portion of HeaderMap. Header names are normalized to lower case. In other words, when creating a HeaderName with a string, even if upper case characters are included, when getting a string representation of the HeaderName, it will be all lower case. This allows for faster HeaderMap comparison operations.

The internal representation is optimized to efficiently handle the cases most commonly encountered when working with HTTP. Standard header names are special cased and are represented internally as an enum. Short custom headers will be stored directly in the HeaderName struct and will not incur any allocation overhead, however longer strings will require an allocation for storage.

Limitations

HeaderName has a max length of 32,768 for header names. Attempting to parse longer names will result in a panic.

HeaderMap

The HeaderMap type is a specialized multimap structure for storing header names and values. It is designed specifically for efficient manipulation of HTTP headers. It supports multiple values per header name and provides specialized APIs for insertion, retrieval, and iteration.

See also the HeaderMap type.

Structs

Enums

Traits

Constants