From d91ec86013b12f9c42c12c9dd7f8e0beeaac9a1f Mon Sep 17 00:00:00 2001 From: Andrey Ermilov Date: Thu, 12 Jun 2025 22:03:12 +0200 Subject: [PATCH 1/2] feat(builder): add title_case_headers --- src/server/conn/auto/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/server/conn/auto/mod.rs b/src/server/conn/auto/mod.rs index b2fc6556..841ed12f 100644 --- a/src/server/conn/auto/mod.rs +++ b/src/server/conn/auto/mod.rs @@ -161,6 +161,31 @@ impl Builder { } } + /// Set whether HTTP/1 connections will write header names as title case at + /// the socket level. + /// + /// This setting only affects HTTP/1 connections. HTTP/2 connections are + /// not affected by this setting. + /// + /// Default is false. + /// + /// # Example + /// + /// ``` + /// use hyper_util::{ + /// rt::TokioExecutor, + /// server::conn::auto, + /// }; + /// + /// auto::Builder::new(TokioExecutor::new()) + /// .title_case_headers(true); + /// ``` + #[cfg(feature = "http1")] + pub fn title_case_headers(mut self, enabled: bool) -> Self { + self.http1.title_case_headers(enabled); + self + } + /// Bind a connection together with a [`Service`]. pub fn serve_connection(&self, io: I, service: S) -> Connection<'_, I, S, E> where @@ -1112,6 +1137,18 @@ mod tests { // builder.serve_connection(io, service); } + #[test] + #[cfg(feature = "http1")] + fn title_case_headers_configuration() { + // Test title_case_headers can be set on the main builder + auto::Builder::new(TokioExecutor::new()).title_case_headers(true); + + // Can be combined with other configuration + auto::Builder::new(TokioExecutor::new()) + .title_case_headers(true) + .http1_only(); + } + #[cfg(not(miri))] #[tokio::test] async fn http1() { From 6a8702b0980552945393364f38cd1746252dda68 Mon Sep 17 00:00:00 2001 From: Andrey Ermilov Date: Thu, 12 Jun 2025 22:29:10 +0200 Subject: [PATCH 2/2] feat(builder): add preserve_header_case --- src/server/conn/auto/mod.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/server/conn/auto/mod.rs b/src/server/conn/auto/mod.rs index 841ed12f..7b887ce2 100644 --- a/src/server/conn/auto/mod.rs +++ b/src/server/conn/auto/mod.rs @@ -186,6 +186,30 @@ impl Builder { self } + /// Set whether HTTP/1 connections will preserve the original case of header names. + /// + /// This setting only affects HTTP/1 connections. HTTP/2 connections are + /// not affected by this setting. + /// + /// Default is false. + /// + /// # Example + /// + /// ``` + /// use hyper_util::{ + /// rt::TokioExecutor, + /// server::conn::auto, + /// }; + /// + /// auto::Builder::new(TokioExecutor::new()) + /// .preserve_header_case(true); + /// ``` + #[cfg(feature = "http1")] + pub fn preserve_header_case(mut self, enabled: bool) -> Self { + self.http1.preserve_header_case(enabled); + self + } + /// Bind a connection together with a [`Service`]. pub fn serve_connection(&self, io: I, service: S) -> Connection<'_, I, S, E> where @@ -1149,6 +1173,18 @@ mod tests { .http1_only(); } + #[test] + #[cfg(feature = "http1")] + fn preserve_header_case_configuration() { + // Test preserve_header_case can be set on the main builder + auto::Builder::new(TokioExecutor::new()).preserve_header_case(true); + + // Can be combined with other configuration + auto::Builder::new(TokioExecutor::new()) + .preserve_header_case(true) + .http1_only(); + } + #[cfg(not(miri))] #[tokio::test] async fn http1() {