@@ -69,6 +69,7 @@ pin_project_lite::pin_project! {
69
69
/// to bind the built connection to a service.
70
70
#[ derive( Clone , Debug ) ]
71
71
pub struct Builder {
72
+ h1_parser_config : httparse:: ParserConfig ,
72
73
timer : Time ,
73
74
h1_half_close : bool ,
74
75
h1_keep_alive : bool ,
@@ -231,6 +232,7 @@ impl Builder {
231
232
/// Create a new connection builder.
232
233
pub fn new ( ) -> Self {
233
234
Self {
235
+ h1_parser_config : Default :: default ( ) ,
234
236
timer : Time :: Empty ,
235
237
h1_half_close : false ,
236
238
h1_keep_alive : true ,
@@ -274,6 +276,19 @@ impl Builder {
274
276
self
275
277
}
276
278
279
+ /// Set whether HTTP/1 connections will silently ignored malformed header lines.
280
+ ///
281
+ /// If this is enabled and a header line does not start with a valid header
282
+ /// name, or does not include a colon at all, the line will be silently ignored
283
+ /// and no error will be reported.
284
+ ///
285
+ /// Default is false.
286
+ pub fn ignore_invalid_headers ( & mut self , enabled : bool ) -> & mut Builder {
287
+ self . h1_parser_config
288
+ . ignore_invalid_headers_in_requests ( enabled) ;
289
+ self
290
+ }
291
+
277
292
/// Set whether to support preserving original header cases.
278
293
///
279
294
/// Currently, this will record the original cases received, and store them
@@ -426,6 +441,7 @@ impl Builder {
426
441
I : Read + Write + Unpin ,
427
442
{
428
443
let mut conn = proto:: Conn :: new ( io) ;
444
+ conn. set_h1_parser_config ( self . h1_parser_config . clone ( ) ) ;
429
445
conn. set_timer ( self . timer . clone ( ) ) ;
430
446
if !self . h1_keep_alive {
431
447
conn. disable_keep_alive ( ) ;
0 commit comments