feat(http1): add options to preserve header casing (#2480)

Decouple preserving header case from FFI:

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.

Closes #2313
This commit is contained in:
Anthony Ramine
2021-04-21 18:50:35 +02:00
committed by GitHub
parent 117cc492a6
commit dbea7716f1
12 changed files with 656 additions and 181 deletions

View File

@@ -126,6 +126,7 @@ pub struct Builder {
h09_responses: bool,
h1_parser_config: ParserConfig,
h1_title_case_headers: bool,
h1_preserve_header_case: bool,
h1_read_buf_exact_size: Option<usize>,
h1_max_buf_size: Option<usize>,
#[cfg(feature = "http2")]
@@ -500,6 +501,7 @@ impl Builder {
h1_read_buf_exact_size: None,
h1_parser_config: Default::default(),
h1_title_case_headers: false,
h1_preserve_header_case: false,
h1_max_buf_size: None,
#[cfg(feature = "http2")]
h2_builder: Default::default(),
@@ -537,6 +539,11 @@ impl Builder {
self
}
pub(crate) fn h1_preserve_header_case(&mut self, enabled: bool) -> &mut Builder {
self.h1_preserve_header_case = enabled;
self
}
pub(super) fn h1_read_buf_exact_size(&mut self, sz: Option<usize>) -> &mut Builder {
self.h1_read_buf_exact_size = sz;
self.h1_max_buf_size = None;
@@ -719,6 +726,9 @@ impl Builder {
if opts.h1_title_case_headers {
conn.set_title_case_headers();
}
if opts.h1_preserve_header_case {
conn.set_preserve_header_case();
}
if opts.h09_responses {
conn.set_h09_responses();
}