From 557a0f382d66ee11d5a83e870b4e72374b1e1f84 Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Sun, 16 Apr 2023 19:00:02 +0200 Subject: [PATCH] use HeaderName::from_static in strip_connection_headers --- src/proto/h2/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/proto/h2/mod.rs b/src/proto/h2/mod.rs index a1cbd25813..8def873cfc 100644 --- a/src/proto/h2/mod.rs +++ b/src/proto/h2/mod.rs @@ -29,21 +29,21 @@ cfg_server! { /// Default initial stream window size defined in HTTP2 spec. pub(crate) const SPEC_WINDOW_SIZE: u32 = 65_535; +// List of connection headers from: +// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection +// +// TE headers are allowed in HTTP/2 requests as long as the value is "trailers", so they're +// tested separately. +const CONNECTION_HEADERS: [HeaderName; 5] = [ + HeaderName::from_static("keep-alive"), + HeaderName::from_static("proxy-connection"), + TRAILER, + TRANSFER_ENCODING, + UPGRADE, +]; + fn strip_connection_headers(headers: &mut HeaderMap, is_request: bool) { - // List of connection headers from: - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection - // - // TE headers are allowed in HTTP/2 requests as long as the value is "trailers", so they're - // tested separately. - let connection_headers = [ - HeaderName::from_lowercase(b"keep-alive").unwrap(), - HeaderName::from_lowercase(b"proxy-connection").unwrap(), - TRAILER, - TRANSFER_ENCODING, - UPGRADE, - ]; - - for header in connection_headers.iter() { + for header in &CONNECTION_HEADERS { if headers.remove(header).is_some() { warn!("Connection header illegal in HTTP/2: {}", header.as_str()); }