Skip to content

Commit c521b50

Browse files
committed
http1 expose ignore_invalid_headers_in_requests opt
1 parent e981a91 commit c521b50

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ futures-channel = { version = "0.3", optional = true }
3131
futures-util = { version = "0.3", default-features = false, optional = true }
3232
h2 = { version = "0.4.2", optional = true }
3333
http-body-util = { version = "0.1", optional = true }
34-
httparse = { version = "1.8", optional = true }
34+
httparse = { version = "1.9", optional = true }
3535
httpdate = { version = "1.0", optional = true }
3636
itoa = { version = "1", optional = true }
3737
pin-project-lite = { version = "0.2.4", optional = true }

src/server/conn/http1.rs

+15
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pin_project_lite::pin_project! {
6969
/// to bind the built connection to a service.
7070
#[derive(Clone, Debug)]
7171
pub struct Builder {
72+
h1_parser_config: httparse::ParserConfig,
7273
timer: Time,
7374
h1_half_close: bool,
7475
h1_keep_alive: bool,
@@ -274,6 +275,19 @@ impl Builder {
274275
self
275276
}
276277

278+
/// Set whether HTTP/1 connections will silently ignored malformed header lines.
279+
///
280+
/// If this is enabled and a header line does not start with a valid header
281+
/// name, or does not include a colon at all, the line will be silently ignored
282+
/// and no error will be reported.
283+
///
284+
/// Default is false.
285+
pub fn ignore_invalid_headers(&mut self, enabled: bool) -> &mut Builder {
286+
self.h1_parser_config
287+
.ignore_invalid_headers_in_requests(enabled);
288+
self
289+
}
290+
277291
/// Set whether to support preserving original header cases.
278292
///
279293
/// Currently, this will record the original cases received, and store them
@@ -426,6 +440,7 @@ impl Builder {
426440
I: Read + Write + Unpin,
427441
{
428442
let mut conn = proto::Conn::new(io);
443+
conn.set_h1_parser_config(self.h1_parser_config.clone());
429444
conn.set_timer(self.timer.clone());
430445
if !self.h1_keep_alive {
431446
conn.disable_keep_alive();

0 commit comments

Comments
 (0)