From ecf1df572c8371ce3988c64f8c16dd9f14a3bb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 22 May 2020 17:05:44 +0200 Subject: [PATCH] =?UTF-8?q?Rename=20option=20to=20=E2=80=9Cpool=5Fmax=5Fid?= =?UTF-8?q?le=5Fper=5Fhost=E2=80=9D=20(#917)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reqwest exposes the “pool_max_idle_per_host” option of hyper’s client builder. This option used to be called “max_idle_per_host” in the hyper crate, but it has recently been renamed [1]. This patch renames the reqwest representation of this option to make it consistent with its name in the hyper crate again. [1] https://github.com/hyperium/hyper/pull/2142 --- src/async_impl/client.rs | 16 +++++++++++----- src/blocking/client.rs | 8 +++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 362e1f8..f088599 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -77,7 +77,7 @@ struct Config { connect_timeout: Option, connection_verbose: bool, pool_idle_timeout: Option, - max_idle_per_host: usize, + pool_max_idle_per_host: usize, #[cfg(feature = "__tls")] identity: Option, proxies: Vec, @@ -127,7 +127,7 @@ impl ClientBuilder { connect_timeout: None, connection_verbose: false, pool_idle_timeout: Some(Duration::from_secs(90)), - max_idle_per_host: std::usize::MAX, + pool_max_idle_per_host: std::usize::MAX, proxies: Vec::new(), auto_sys_proxy: true, redirect_policy: redirect::Policy::default(), @@ -307,7 +307,7 @@ impl ClientBuilder { } builder.pool_idle_timeout(config.pool_idle_timeout); - builder.pool_max_idle_per_host(config.max_idle_per_host); + builder.pool_max_idle_per_host(config.pool_max_idle_per_host); if config.http1_title_case_headers { builder.http1_title_case_headers(true); @@ -613,11 +613,17 @@ impl ClientBuilder { } /// Sets the maximum idle connection per host allowed in the pool. - pub fn max_idle_per_host(mut self, max: usize) -> ClientBuilder { - self.config.max_idle_per_host = max; + pub fn pool_max_idle_per_host(mut self, max: usize) -> ClientBuilder { + self.config.pool_max_idle_per_host = max; self } + #[doc(hidden)] + #[deprecated(note = "renamed to `pool_max_idle_per_host`")] + pub fn max_idle_per_host(self, max: usize) -> ClientBuilder { + self.pool_max_idle_per_host(max) + } + /// Enable case sensitive headers. pub fn http1_title_case_headers(mut self) -> ClientBuilder { self.config.http1_title_case_headers = true; diff --git a/src/blocking/client.rs b/src/blocking/client.rs index 656d710..ebe1dbc 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -309,8 +309,14 @@ impl ClientBuilder { } /// Sets the maximum idle connection per host allowed in the pool. + pub fn pool_max_idle_per_host(self, max: usize) -> ClientBuilder { + self.with_inner(move |inner| inner.pool_max_idle_per_host(max)) + } + + #[doc(hidden)] + #[deprecated(note = "use pool_max_idle_per_host instead")] pub fn max_idle_per_host(self, max: usize) -> ClientBuilder { - self.with_inner(move |inner| inner.max_idle_per_host(max)) + self.pool_max_idle_per_host(max) } /// Enable case sensitive headers.