Skip to content

Commit

Permalink
Expose http1_writev config option to user (seanmonstar#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snarpix authored Sep 18, 2020
1 parent 5031747 commit dbd887c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct Config {
#[cfg(feature = "__tls")]
tls: TlsBackend,
http2_only: bool,
http1_writev: Option<bool>,
http1_title_case_headers: bool,
http2_initial_stream_window_size: Option<u32>,
http2_initial_connection_window_size: Option<u32>,
Expand Down Expand Up @@ -142,6 +143,7 @@ impl ClientBuilder {
#[cfg(feature = "__tls")]
tls: TlsBackend::default(),
http2_only: false,
http1_writev: None,
http1_title_case_headers: false,
http2_initial_stream_window_size: None,
http2_initial_connection_window_size: None,
Expand Down Expand Up @@ -299,6 +301,10 @@ impl ClientBuilder {
builder.http2_only(true);
}

if let Some(http1_writev) = config.http1_writev {
builder.http1_writev(http1_writev);
}

if let Some(http2_initial_stream_window_size) = config.http2_initial_stream_window_size {
builder.http2_initial_stream_window_size(http2_initial_stream_window_size);
}
Expand Down Expand Up @@ -632,6 +638,14 @@ impl ClientBuilder {
self
}

/// Force hyper to use either queued(if true), or flattened(if false) write strategy
/// This may eliminate unnecessary cloning of buffers for some TLS backends
/// By default hyper will try to guess which strategy to use
pub fn http1_writev(mut self, writev: bool) -> ClientBuilder {
self.config.http1_writev = Some(writev);
self
}

/// Only use HTTP/2.
pub fn http2_prior_knowledge(mut self) -> ClientBuilder {
self.config.http2_only = true;
Expand Down

0 comments on commit dbd887c

Please sign in to comment.