Crate headers
Expand description
§Typed HTTP Headers
rama has the opinion that headers should be strongly-typed, because that’s
why we’re using Rust in the first place. To set or get any header, an object
must implement the Header trait from this module. Several common headers
are already provided, such as Host, ContentType, UserAgent, and others.
§Why Typed?
Or, why not stringly-typed? Types give the following advantages:
- More difficult to typo, since typos in types should be caught by the compiler
- Parsing to a proper type by default
§Rama
Crate used by the end-user rama crate and rama crate authors alike.
Learn more about rama:
- Github: https://github.com/plabayo/rama
- Book: https://ramaproxy.org/book/
Modules§
- authorization
- Authorization header and types.
- encoding
- Utility types and functions that can be used in context of encoding headers.
- forwarded
- privacy
- Privacy-related typed headers.
- sec_
websocket_ extensions - Sec-WebSocket-Extensions header value types.
- sec_
websocket_ protocol - specifier
- Specifiers that can be used as part of header values.
- util
- x_
robots_ tag
Structs§
- Accept
Acceptheader, defined in RFC7231- Accept
Ranges Accept-Rangesheader, defined in RFC7233- Access
Control Allow Credentials Access-Control-Allow-Credentialsheader, part of CORS- Access
Control Allow Headers Access-Control-Allow-Headersheader, part of CORS- Access
Control Allow Methods Access-Control-Allow-Methodsheader, part of CORS- Access
Control Allow Origin - The
Access-Control-Allow-Originresponse header, part of CORS - Access
Control Expose Headers Access-Control-Expose-Headersheader, part of CORS- Access
Control MaxAge Access-Control-Max-Ageheader, part of CORS- Access
Control Request Headers Access-Control-Request-Headersheader, part of CORS- Access
Control Request Method Access-Control-Request-Methodheader, part of CORS- Age
Ageheader, defined in RFC7234- Allow
Allowheader, defined in RFC7231- Authorization
Authorizationheader, defined in RFC7235- Cache
Control Cache-Controlheader, defined in RFC7234 with extensions in RFC8246- Connection
Connectionheader, defined in RFC7230- Content
Disposition - A
Content-Dispositionheader, (re)defined in RFC6266. - Content
Encoding Content-Encodingheader, defined in RFC7231- Content
Length Content-Lengthheader, defined in RFC7230- Content
Location Content-Locationheader, defined in RFC7231- Content
Range - Content-Range, described in RFC7233
- Content
Type Content-Typeheader, defined in RFC7231- Cookie
Cookieheader, defined in RFC6265- Date
Dateheader, defined in RFC7231- ETag
ETagheader, defined in RFC7232- Error
- Errors trying to decode a header.
- Expect
- The
Expectheader. - Expires
Expiresheader, defined in RFC7234- Host
- The
Hostheader. - IfMatch
If-Matchheader, defined in RFC7232- IfModified
Since If-Modified-Sinceheader, defined in RFC7232- IfNone
Match If-None-Matchheader, defined in RFC7232- IfRange
If-Rangeheader, defined in RFC7233- IfUnmodified
Since If-Unmodified-Sinceheader, defined in RFC7232- Last
Event Id Last-Event-IDheader, defined in WhatWG’s SSE spec- Last
Modified Last-Modifiedheader, defined in RFC7232- Location
Locationheader, defined in RFC7231- Origin
- The
Originheader. - Pragma
- The
Pragmaheader defined by HTTP/1.0. - Proxy
Authorization Proxy-Authorizationheader, defined in RFC7235- Range
Rangeheader, defined in RFC7233- Referer
Refererheader, defined in RFC7231- Referrer
Policy Referrer-Policyheader, part of Referrer Policy- Retry
After - The
Retry-Afterheader. - SecWeb
Socket Accept - The
Sec-WebSocket-Acceptheader. - SecWeb
Socket Extensions - The
Sec-WebSocket-Extensionsheader, containing one or multipleExtensions. - SecWeb
Socket Key - The
Sec-WebSocket-Keyheader. - SecWeb
Socket Protocol - The
Sec-WebSocket-Protocolheader, containing one or multiple protocols. - SecWeb
Socket Version - The
Sec-WebSocket-Versionheader. - Server
Serverheader, defined in RFC7231- SetCookie
Set-Cookieheader, defined RFC6265- Strict
Transport Security StrictTransportSecurityheader, defined in RFC6797- Te
TEheader, defined in RFC7230- Transfer
Encoding Transfer-Encodingheader, defined in RFC7230- Upgrade
Upgradeheader, defined in RFC7230- User
Agent User-Agentheader, defined in RFC7231- Vary
Varyheader, defined in RFC7231- XRobots
Tag
Enums§
Traits§
- Header
Decode - A typed header which can be decoded from one or multiple headers.
- Header
Encode - A typed header which can be encoded into one or multiple headers.
- Header
MapExt - An extension trait adding “typed” methods to
http::HeaderMap. - Http
Request Builder Ext - An extension trait adding “typed” methods to
http::request::Builder. - Http
Response Builder Ext - An extension trait adding “typed” methods to
http::response::Builder. - Typed
Header - Base trait for a typed header.
Functions§
- all_
client_ hint_ header_ name_ strings - Returns an iterator over all client hint header name strings.
- all_
client_ hint_ header_ names - Returns an iterator over all client hint header names.
- all_
client_ hints - Returns an iterator over all client hints.