Skip to main content

Module remove_header

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§

request
Remove headers from a request.
response
Remove headers from a response.

Structs§

HopByHopHeaderContext
Connection-specific metadata captured while sanitizing an HTTP message.
RemoveRequestHeader
Middleware that removes headers from a request.
RemoveRequestHeaderLayer
Layer that applies RemoveRequestHeader which removes request headers.
RemoveResponseHeader
Middleware that removes response headers from a request.
RemoveResponseHeaderLayer
Layer that applies RemoveResponseHeader which removes response headers.

Enums§

HopByHopResponseDisposition
Action a caller must take after sanitizing a response.

Functions§

coalesce_cookie_headers
Coalesce multiple Cookie request 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 Connection nominations.
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.