Skip to main content

remove_illegal_h2_response_headers

Function remove_illegal_h2_response_headers 

pub fn remove_illegal_h2_response_headers(headers: &mut HeaderMap)
Available on crate features http and std only.
Expand description

Remove headers that are illegal on an HTTP/2 (or HTTP/3) response.

HTTP/2 forbids connection-specific (hop-by-hop) header fields (RFC 9113 §8.2.2). This removes only those headers (including any named by a Connection header) so that a response can be (re)serialized over HTTP/2.

Unlike remove_hop_by_hop_response_headers, this is a pure protocol-legality operation, not a proxy forwarding policy: it leaves headers that are perfectly legal in HTTP/2 such as Trailer and Proxy-Authenticate. Use this when merely changing a message’s HTTP version (which may happen on the same server, with no downstream hop), and use remove_hop_by_hop_response_headers when actually relaying a response across a connection hop.