Skip to content

Commit 129a448

Browse files
committed
http1 expose ignore_invalid_headers_in_requests opt
1 parent e981a91 commit 129a448

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

Cargo.toml

+27-22
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ repository = "https://github.com/hyperium/hyper"
99
license = "MIT"
1010
authors = ["Sean McArthur <[email protected]>"]
1111
keywords = ["http", "hyper", "hyperium"]
12-
categories = ["network-programming", "web-programming::http-client", "web-programming::http-server"]
12+
categories = [
13+
"network-programming",
14+
"web-programming::http-client",
15+
"web-programming::http-server",
16+
]
1317
edition = "2021"
1418
rust-version = "1.63" # keep in sync with MSRV.md dev doc
1519

16-
include = [
17-
"Cargo.toml",
18-
"LICENSE",
19-
"src/**/*",
20-
]
20+
include = ["Cargo.toml", "LICENSE", "src/**/*"]
2121

2222
[dependencies]
2323
bytes = "1.2"
@@ -31,18 +31,26 @@ 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 }
38-
smallvec = { version = "1.12", features = ["const_generics", "const_new"], optional = true }
39-
tracing = { version = "0.1", default-features = false, features = ["std"], optional = true }
38+
smallvec = { version = "1.12", features = [
39+
"const_generics",
40+
"const_new",
41+
], optional = true }
42+
tracing = { version = "0.1", default-features = false, features = [
43+
"std",
44+
], optional = true }
4045
want = { version = "0.3", optional = true }
4146

4247
[dev-dependencies]
4348
form_urlencoded = "1"
4449
futures-channel = { version = "0.3", features = ["sink"] }
45-
futures-util = { version = "0.3", default-features = false, features = ["alloc", "sink"] }
50+
futures-util = { version = "0.3", default-features = false, features = [
51+
"alloc",
52+
"sink",
53+
] }
4654
http-body-util = "0.1"
4755
pretty_env_logger = "0.5"
4856
pin-project-lite = "0.2.4"
@@ -69,12 +77,7 @@ tokio-util = "0.7.10"
6977
default = []
7078

7179
# Easily turn it all on
72-
full = [
73-
"client",
74-
"http1",
75-
"http2",
76-
"server",
77-
]
80+
full = ["client", "http1", "http2", "server"]
7881

7982
# HTTP versions
8083
http1 = ["dep:futures-channel", "dep:futures-util", "dep:httparse", "dep:itoa"]
@@ -96,14 +99,16 @@ nightly = []
9699

97100
[lints.rust.unexpected_cfgs]
98101
level = "warn"
99-
check-cfg = [
100-
'cfg(hyper_unstable_tracing)',
101-
'cfg(hyper_unstable_ffi)'
102-
]
102+
check-cfg = ['cfg(hyper_unstable_tracing)', 'cfg(hyper_unstable_ffi)']
103103

104104
[package.metadata.docs.rs]
105105
features = ["ffi", "full", "tracing"]
106-
rustdoc-args = ["--cfg", "hyper_unstable_ffi", "--cfg", "hyper_unstable_tracing"]
106+
rustdoc-args = [
107+
"--cfg",
108+
"hyper_unstable_ffi",
109+
"--cfg",
110+
"hyper_unstable_tracing",
111+
]
107112

108113
[package.metadata.playground]
109114
features = ["full"]
@@ -113,7 +118,7 @@ generation = false
113118
subdirectory = false
114119

115120
[package.metadata.capi.install.include]
116-
asset = [{ from="capi/include/hyper.h" }]
121+
asset = [{ from = "capi/include/hyper.h" }]
117122

118123
[profile.release]
119124
codegen-units = 1

src/client/conn/http1.rs

+13
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,19 @@ impl Builder {
402402
self
403403
}
404404

405+
/// Set whether HTTP/1 connections will silently ignored malformed header lines.
406+
///
407+
/// If this is enabled and a header line does not start with a valid header
408+
/// name, or does not include a colon at all, the line will be silently ignored
409+
/// and no error will be reported.
410+
///
411+
/// Default is false.
412+
pub fn ignore_invalid_headers_in_requests(&mut self, enabled: bool) -> &mut Builder {
413+
self.h1_parser_config
414+
.ignore_invalid_headers_in_requests(enabled);
415+
self
416+
}
417+
405418
/// Set whether HTTP/1 connections should try to use vectored writes,
406419
/// or always flatten into a single buffer.
407420
///

0 commit comments

Comments
 (0)