Enable ClientBuilder to be configure with http1_allow_obsolete_multiline_headers_in_responses (#1521) (#1523)
This commit is contained in:
@@ -95,7 +95,7 @@ encoding_rs = "0.8"
|
||||
futures-core = { version = "0.3.0", default-features = false }
|
||||
futures-util = { version = "0.3.0", default-features = false }
|
||||
http-body = "0.4.0"
|
||||
hyper = { version = "0.14.5", default-features = false, features = ["tcp", "http1", "http2", "client", "runtime"] }
|
||||
hyper = { version = "0.14.18", default-features = false, features = ["tcp", "http1", "http2", "client", "runtime"] }
|
||||
h2 = "0.3.10"
|
||||
lazy_static = "1.4"
|
||||
log = "0.4"
|
||||
|
||||
@@ -105,6 +105,7 @@ struct Config {
|
||||
http_version_pref: HttpVersionPref,
|
||||
http09_responses: bool,
|
||||
http1_title_case_headers: bool,
|
||||
http1_allow_obsolete_multiline_headers_in_responses: bool,
|
||||
http2_initial_stream_window_size: Option<u32>,
|
||||
http2_initial_connection_window_size: Option<u32>,
|
||||
http2_adaptive_window: bool,
|
||||
@@ -169,6 +170,7 @@ impl ClientBuilder {
|
||||
http_version_pref: HttpVersionPref::All,
|
||||
http09_responses: false,
|
||||
http1_title_case_headers: false,
|
||||
http1_allow_obsolete_multiline_headers_in_responses: false,
|
||||
http2_initial_stream_window_size: None,
|
||||
http2_initial_connection_window_size: None,
|
||||
http2_adaptive_window: false,
|
||||
@@ -487,6 +489,10 @@ impl ClientBuilder {
|
||||
builder.http1_title_case_headers(true);
|
||||
}
|
||||
|
||||
if config.http1_allow_obsolete_multiline_headers_in_responses {
|
||||
builder.http1_allow_obsolete_multiline_headers_in_responses(true);
|
||||
}
|
||||
|
||||
let hyper_client = builder.build(connector);
|
||||
|
||||
let proxies_maybe_http_auth = proxies.iter().any(|p| p.maybe_has_http_auth());
|
||||
@@ -861,6 +867,20 @@ impl ClientBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set whether HTTP/1 connections will accept obsolete line folding for
|
||||
/// header values.
|
||||
///
|
||||
/// Newline codepoints (`\r` and `\n`) will be transformed to spaces when
|
||||
/// parsing.
|
||||
pub fn http1_allow_obsolete_multiline_headers_in_responses(
|
||||
mut self,
|
||||
value: bool,
|
||||
) -> ClientBuilder {
|
||||
self.config
|
||||
.http1_allow_obsolete_multiline_headers_in_responses = value;
|
||||
self
|
||||
}
|
||||
|
||||
/// Only use HTTP/1.
|
||||
pub fn http1_only(mut self) -> ClientBuilder {
|
||||
self.config.http_version_pref = HttpVersionPref::Http1;
|
||||
@@ -1535,6 +1555,10 @@ impl Config {
|
||||
f.field("http1_title_case_headers", &true);
|
||||
}
|
||||
|
||||
if self.http1_allow_obsolete_multiline_headers_in_responses {
|
||||
f.field("http1_allow_obsolete_multiline_headers_in_responses", &true);
|
||||
}
|
||||
|
||||
if matches!(self.http_version_pref, HttpVersionPref::Http1) {
|
||||
f.field("http1_only", &true);
|
||||
}
|
||||
|
||||
@@ -407,6 +407,15 @@ impl ClientBuilder {
|
||||
self.with_inner(|inner| inner.http1_title_case_headers())
|
||||
}
|
||||
|
||||
/// Set whether HTTP/1 connections will accept obsolete line folding for
|
||||
/// header values.
|
||||
///
|
||||
/// Newline codepoints (`\r` and `\n`) will be transformed to spaces when
|
||||
/// parsing.
|
||||
pub fn http1_allow_obsolete_multiline_headers_in_responses(self, value: bool) -> ClientBuilder {
|
||||
self.with_inner(|inner| inner.http1_allow_obsolete_multiline_headers_in_responses(value))
|
||||
}
|
||||
|
||||
/// Only use HTTP/1.
|
||||
pub fn http1_only(self) -> ClientBuilder {
|
||||
self.with_inner(|inner| inner.http1_only())
|
||||
|
||||
Reference in New Issue
Block a user