@@ -69,6 +69,7 @@ pin_project_lite::pin_project! {
6969/// to bind the built connection to a service.
7070#[ derive( Clone , Debug ) ]
7171pub struct Builder {
72+ h1_parser_config : httparse:: ParserConfig ,
7273 timer : Time ,
7374 h1_half_close : bool ,
7475 h1_keep_alive : bool ,
@@ -231,6 +232,7 @@ impl Builder {
231232 /// Create a new connection builder.
232233 pub fn new ( ) -> Self {
233234 Self {
235+ h1_parser_config : Default :: default ( ) ,
234236 timer : Time :: Empty ,
235237 h1_half_close : false ,
236238 h1_keep_alive : true ,
@@ -274,6 +276,19 @@ impl Builder {
274276 self
275277 }
276278
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+
277292 /// Set whether to support preserving original header cases.
278293 ///
279294 /// Currently, this will record the original cases received, and store them
@@ -426,6 +441,7 @@ impl Builder {
426441 I : Read + Write + Unpin ,
427442 {
428443 let mut conn = proto:: Conn :: new ( io) ;
444+ conn. set_h1_parser_config ( self . h1_parser_config . clone ( ) ) ;
429445 conn. set_timer ( self . timer . clone ( ) ) ;
430446 if !self . h1_keep_alive {
431447 conn. disable_keep_alive ( ) ;
0 commit comments