added max_idle_per_host as an option to the builder (#473)
This commit is contained in:
		| @@ -67,6 +67,7 @@ struct Config { | |||||||
|     #[cfg(feature = "tls")] |     #[cfg(feature = "tls")] | ||||||
|     certs_verification: bool, |     certs_verification: bool, | ||||||
|     connect_timeout: Option<Duration>, |     connect_timeout: Option<Duration>, | ||||||
|  |     max_idle_per_host: usize, | ||||||
|     #[cfg(feature = "tls")] |     #[cfg(feature = "tls")] | ||||||
|     identity: Option<Identity>, |     identity: Option<Identity>, | ||||||
|     proxies: Vec<Proxy>, |     proxies: Vec<Proxy>, | ||||||
| @@ -100,6 +101,7 @@ impl ClientBuilder { | |||||||
|                 #[cfg(feature = "tls")] |                 #[cfg(feature = "tls")] | ||||||
|                 certs_verification: true, |                 certs_verification: true, | ||||||
|                 connect_timeout: None, |                 connect_timeout: None, | ||||||
|  |                 max_idle_per_host: ::std::usize::MAX, | ||||||
|                 proxies: Vec::new(), |                 proxies: Vec::new(), | ||||||
|                 redirect_policy: RedirectPolicy::default(), |                 redirect_policy: RedirectPolicy::default(), | ||||||
|                 referer: true, |                 referer: true, | ||||||
| @@ -188,6 +190,8 @@ impl ClientBuilder { | |||||||
|             builder.http2_only(true); |             builder.http2_only(true); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         builder.max_idle_per_host(config.max_idle_per_host); | ||||||
|  |  | ||||||
|         if config.http1_title_case_headers { |         if config.http1_title_case_headers { | ||||||
|             builder.http1_title_case_headers(true); |             builder.http1_title_case_headers(true); | ||||||
|         } |         } | ||||||
| @@ -329,6 +333,14 @@ impl ClientBuilder { | |||||||
|         self |         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. |     /// Only use HTTP/2. | ||||||
|     pub fn h2_prior_knowledge(mut self) -> ClientBuilder { |     pub fn h2_prior_knowledge(mut self) -> ClientBuilder { | ||||||
|         self.config.http2_only = true; |         self.config.http2_only = true; | ||||||
|   | |||||||
| @@ -288,6 +288,13 @@ impl ClientBuilder { | |||||||
|         self |         self | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Sets the maximum idle connection per host allowed in the pool. | ||||||
|  |     /// | ||||||
|  |     /// Default is usize::MAX (no limit). | ||||||
|  |     pub fn max_idle_per_host(self, max: usize) -> ClientBuilder { | ||||||
|  |         self.with_inner(move |inner| inner.max_idle_per_host(max)) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /// Set a timeout for only the connect phase of a `Client`. |     /// Set a timeout for only the connect phase of a `Client`. | ||||||
|     /// |     /// | ||||||
|     /// Default is `None`. |     /// Default is `None`. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user