Enable "system" proxies by default (#683)

If no proxies are configured for a client, the environment (system) will
be inspected automatically to set up proxies.

Configuring a `Proxy` on a client or calling `no_proxy` will disable the
use of the automatic system proxy.

Closes #403
This commit is contained in:
Sean McArthur
2019-10-17 13:32:00 -07:00
committed by GitHub
parent 8583dd2b4c
commit 7739e03123
7 changed files with 87 additions and 47 deletions

View File

@@ -193,18 +193,25 @@ impl ClientBuilder {
// Proxy options
/// Add a `Proxy` to the list of proxies the `Client` will use.
///
/// # Note
///
/// Adding a proxy will disable the automatic usage of the "system" proxy.
pub fn proxy(self, proxy: Proxy) -> ClientBuilder {
self.with_inner(move |inner| inner.proxy(proxy))
}
/// Disable proxy setting.
/// Clear all `Proxies`, so `Client` will use no proxy anymore.
///
/// This also disables the automatic usage of the "system" proxy.
pub fn no_proxy(self) -> ClientBuilder {
self.with_inner(move |inner| inner.no_proxy())
}
/// Enable system proxy setting.
#[doc(hidden)]
#[deprecated(note = "the system proxy is used automatically")]
pub fn use_sys_proxy(self) -> ClientBuilder {
self.with_inner(move |inner| inner.use_sys_proxy())
self
}
// Timeout options