added max_idle_per_host as an option to the builder (#473)

This commit is contained in:
CJP10
2019-03-19 16:23:32 -04:00
committed by Sean McArthur
parent 3554b0ad26
commit a54bfc1a39
2 changed files with 19 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ struct Config {
#[cfg(feature = "tls")]
certs_verification: bool,
connect_timeout: Option<Duration>,
max_idle_per_host: usize,
#[cfg(feature = "tls")]
identity: Option<Identity>,
proxies: Vec<Proxy>,
@@ -100,6 +101,7 @@ impl ClientBuilder {
#[cfg(feature = "tls")]
certs_verification: true,
connect_timeout: None,
max_idle_per_host: ::std::usize::MAX,
proxies: Vec::new(),
redirect_policy: RedirectPolicy::default(),
referer: true,
@@ -188,6 +190,8 @@ impl ClientBuilder {
builder.http2_only(true);
}
builder.max_idle_per_host(config.max_idle_per_host);
if config.http1_title_case_headers {
builder.http1_title_case_headers(true);
}
@@ -329,6 +333,14 @@ impl ClientBuilder {
self
}
/// Sets the maximum idle connection per host allowed in the pool.
//
// Default is usize::MAX (no limit).
pub fn max_idle_per_host(mut self, max: usize) -> ClientBuilder {
self.config.max_idle_per_host = max;
self
}
/// Only use HTTP/2.
pub fn h2_prior_knowledge(mut self) -> ClientBuilder {
self.config.http2_only = true;