Skip to content

Commit dbd887c

Browse files
authored
Expose http1_writev config option to user (#1040)
1 parent 5031747 commit dbd887c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/async_impl/client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct Config {
9292
#[cfg(feature = "__tls")]
9393
tls: TlsBackend,
9494
http2_only: bool,
95+
http1_writev: Option<bool>,
9596
http1_title_case_headers: bool,
9697
http2_initial_stream_window_size: Option<u32>,
9798
http2_initial_connection_window_size: Option<u32>,
@@ -142,6 +143,7 @@ impl ClientBuilder {
142143
#[cfg(feature = "__tls")]
143144
tls: TlsBackend::default(),
144145
http2_only: false,
146+
http1_writev: None,
145147
http1_title_case_headers: false,
146148
http2_initial_stream_window_size: None,
147149
http2_initial_connection_window_size: None,
@@ -299,6 +301,10 @@ impl ClientBuilder {
299301
builder.http2_only(true);
300302
}
301303

304+
if let Some(http1_writev) = config.http1_writev {
305+
builder.http1_writev(http1_writev);
306+
}
307+
302308
if let Some(http2_initial_stream_window_size) = config.http2_initial_stream_window_size {
303309
builder.http2_initial_stream_window_size(http2_initial_stream_window_size);
304310
}
@@ -632,6 +638,14 @@ impl ClientBuilder {
632638
self
633639
}
634640

641+
/// Force hyper to use either queued(if true), or flattened(if false) write strategy
642+
/// This may eliminate unnecessary cloning of buffers for some TLS backends
643+
/// By default hyper will try to guess which strategy to use
644+
pub fn http1_writev(mut self, writev: bool) -> ClientBuilder {
645+
self.config.http1_writev = Some(writev);
646+
self
647+
}
648+
635649
/// Only use HTTP/2.
636650
pub fn http2_prior_knowledge(mut self) -> ClientBuilder {
637651
self.config.http2_only = true;

0 commit comments

Comments
 (0)