@@ -161,6 +161,55 @@ impl<E> Builder<E> {
161
161
}
162
162
}
163
163
164
+ /// Set whether HTTP/1 connections will write header names as title case at
165
+ /// the socket level.
166
+ ///
167
+ /// This setting only affects HTTP/1 connections. HTTP/2 connections are
168
+ /// not affected by this setting.
169
+ ///
170
+ /// Default is false.
171
+ ///
172
+ /// # Example
173
+ ///
174
+ /// ```
175
+ /// use hyper_util::{
176
+ /// rt::TokioExecutor,
177
+ /// server::conn::auto,
178
+ /// };
179
+ ///
180
+ /// auto::Builder::new(TokioExecutor::new())
181
+ /// .title_case_headers(true);
182
+ /// ```
183
+ #[ cfg( feature = "http1" ) ]
184
+ pub fn title_case_headers ( mut self , enabled : bool ) -> Self {
185
+ self . http1 . title_case_headers ( enabled) ;
186
+ self
187
+ }
188
+
189
+ /// Set whether HTTP/1 connections will preserve the original case of header names.
190
+ ///
191
+ /// This setting only affects HTTP/1 connections. HTTP/2 connections are
192
+ /// not affected by this setting.
193
+ ///
194
+ /// Default is false.
195
+ ///
196
+ /// # Example
197
+ ///
198
+ /// ```
199
+ /// use hyper_util::{
200
+ /// rt::TokioExecutor,
201
+ /// server::conn::auto,
202
+ /// };
203
+ ///
204
+ /// auto::Builder::new(TokioExecutor::new())
205
+ /// .preserve_header_case(true);
206
+ /// ```
207
+ #[ cfg( feature = "http1" ) ]
208
+ pub fn preserve_header_case ( mut self , enabled : bool ) -> Self {
209
+ self . http1 . preserve_header_case ( enabled) ;
210
+ self
211
+ }
212
+
164
213
/// Bind a connection together with a [`Service`].
165
214
pub fn serve_connection < I , S , B > ( & self , io : I , service : S ) -> Connection < ' _ , I , S , E >
166
215
where
@@ -1112,6 +1161,30 @@ mod tests {
1112
1161
// builder.serve_connection(io, service);
1113
1162
}
1114
1163
1164
+ #[ test]
1165
+ #[ cfg( feature = "http1" ) ]
1166
+ fn title_case_headers_configuration ( ) {
1167
+ // Test title_case_headers can be set on the main builder
1168
+ auto:: Builder :: new ( TokioExecutor :: new ( ) ) . title_case_headers ( true ) ;
1169
+
1170
+ // Can be combined with other configuration
1171
+ auto:: Builder :: new ( TokioExecutor :: new ( ) )
1172
+ . title_case_headers ( true )
1173
+ . http1_only ( ) ;
1174
+ }
1175
+
1176
+ #[ test]
1177
+ #[ cfg( feature = "http1" ) ]
1178
+ fn preserve_header_case_configuration ( ) {
1179
+ // Test preserve_header_case can be set on the main builder
1180
+ auto:: Builder :: new ( TokioExecutor :: new ( ) ) . preserve_header_case ( true ) ;
1181
+
1182
+ // Can be combined with other configuration
1183
+ auto:: Builder :: new ( TokioExecutor :: new ( ) )
1184
+ . preserve_header_case ( true )
1185
+ . http1_only ( ) ;
1186
+ }
1187
+
1115
1188
#[ cfg( not( miri) ) ]
1116
1189
#[ tokio:: test]
1117
1190
async fn http1 ( ) {
0 commit comments