Module remove_header
Available on crate features
http and std only.Expand description
Middleware for removing headers from requests and responses.
For an HTTP intermediary, the context-aware hop-by-hop pair is the recommended default. When using transform middleware, place the request layer outside it and the response layer inside it. This consumes fields belonging to each incoming hop before the middleware handles the message, while fields originated by the middleware remain available to the next hop:
use rama_core::{Layer, service::service_fn};
use rama_http::{Body, Request, Response};
use rama_http::layer::remove_header::{
RemoveRequestHeaderLayer, RemoveResponseHeaderLayer,
};
let client = service_fn(async |_request: Request| {
Ok::<_, std::convert::Infallible>(Response::new(Body::empty()))
});
let proxy = (
RemoveRequestHeaderLayer::hop_by_hop(),
// transform middleware goes here
RemoveResponseHeaderLayer::hop_by_hop(),
).into_layer(client);Use the hop_by_hop_strict layer constructors only when upgrade and
trailer capabilities are intentionally unsupported. See request and
response for the other removal policies.
Modules§
Structs§
- HopBy
HopHeader Context - Connection-specific metadata captured while sanitizing an HTTP message.
- Remove
Request Header - Middleware that removes headers from a request.
- Remove
Request Header Layer - Layer that applies
RemoveRequestHeaderwhich removes request headers. - Remove
Response Header - Middleware that removes response headers from a request.
- Remove
Response Header Layer - Layer that applies
RemoveResponseHeaderwhich removes response headers.
Enums§
- HopBy
HopResponse Disposition - Action a caller must take after sanitizing a response.
Functions§
- coalesce_
cookie_ headers - Coalesce multiple
Cookierequest header fields into a single field. - connection_
header_ names - Return every syntactically valid field name nominated by
Connection. - hop_
by_ hop_ header_ names - Return known hop-by-hop field names and valid
Connectionnominations. - remove_
cache_ policy_ headers - Remove caching policy headers.
- remove_
cache_ validation_ request_ headers - Remove cache validation and conditional request headers.
- remove_
cache_ validation_ response_ headers - Remove cache validators and representation range metadata from a response.
- remove_
forwarding_ metadata_ request_ headers - Remove request headers that describe the forwarding chain or client address.
- remove_
hop_ by_ hop_ headers - Remove all hop-by-hop headers from an HTTP message.
- remove_
hop_ by_ hop_ request_ headers - Remove request-side hop-by-hop fields without forwarding capabilities.
- remove_
hop_ by_ hop_ response_ headers - Remove response-side hop-by-hop fields without forwarding capabilities.
- remove_
illegal_ h2_ request_ headers - Remove headers that are illegal on an HTTP/2 (or HTTP/3) request.
- remove_
illegal_ h2_ response_ headers - Remove headers that are illegal on an HTTP/2 (or HTTP/3) response.
- remove_
payload_ metadata_ headers - Remove headers that describe or affect payload framing.
- remove_
proxy_ auth_ request_ headers - Remove credentials addressed to the current proxy from a request.
- remove_
proxy_ auth_ response_ headers - Remove proxy authentication fields from a response.
- remove_
sensitive_ request_ headers - Remove sensitive headers from an outbound request.
- remove_
sensitive_ response_ headers - Remove sensitive headers from an outbound response.
- sanitize_
hop_ by_ hop_ request_ headers - Sanitize an outbound request while preserving valid next-hop metadata.
- sanitize_
hop_ by_ hop_ response - Sanitize a response for forwarding to the next hop.
- sanitize_
hop_ by_ hop_ response_ headers - Sanitize an outbound response using its corresponding request context.