diff --git a/src/client/http.rs b/src/client/http.rs
index e4791427..b1245fea 100644
--- a/src/client/http.rs
+++ b/src/client/http.rs
@@ -6,6 +6,7 @@ use std::time::Duration;
use std::{collections::HashMap, convert::TryInto, net::SocketAddr};
use std::{fmt, str};
+use crate::util::client::{InnerRequest, NetworkScheme};
use crate::util::{
self, client::connect::HttpConnector, client::Builder, common::Exec, rt::TokioExecutor,
};
@@ -24,7 +25,7 @@ use std::task::{Context, Poll};
use tokio::time::Sleep;
use super::decoder::Accepts;
-use super::request::{InnerRequest, Request, RequestBuilder};
+use super::request::{Request, RequestBuilder};
use super::response::Response;
use super::Body;
use crate::connect::Connector;
@@ -204,8 +205,6 @@ impl ClientBuilder {
if config.auto_sys_proxy {
proxies.push(Proxy::system());
}
- let proxies = Arc::new(proxies);
-
let proxies_maybe_http_auth = proxies.iter().any(|p| p.maybe_has_http_auth());
let mut connector = {
@@ -233,17 +232,7 @@ impl ClientBuilder {
http.set_connect_timeout(config.connect_timeout);
let tls = BoringTlsConnector::new(config.tls)?;
- Connector::new_boring_tls(
- http,
- tls,
- proxies,
- config.local_address_ipv4,
- config.local_address_ipv6,
- #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
- config.interface,
- config.nodelay,
- config.tls_info,
- )
+ Connector::new_boring_tls(http, tls, config.nodelay, config.tls_info)
};
connector.set_timeout(config.connect_timeout);
@@ -272,6 +261,12 @@ impl ClientBuilder {
proxies_maybe_http_auth,
base_url: config.base_url.map(Arc::new),
http2_max_retry_count: config.http2_max_retry_count,
+
+ proxies,
+ local_addr_v4: config.local_address_ipv4,
+ local_addr_v6: config.local_address_ipv6,
+ #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
+ interface: config.interface,
}),
})
}
@@ -1303,15 +1298,14 @@ impl Client {
self.inner.proxy_auth(&uri, &mut headers);
let in_flight = {
- let pool_key = self.inner.hyper.pool_key(&uri);
- let req = InnerRequest::new()
+ let req = InnerRequest::
::builder()
+ .network_scheme(self.inner.network_scheme(&uri, None))
.uri(uri)
.method(method.clone())
.version(version)
.headers(headers.clone())
.headers_order(self.inner.headers_order.as_deref())
- .pool_key(pool_key)
- .build(body);
+ .body(body);
ResponseFuture::Default(self.inner.hyper.request(req))
};
@@ -1411,33 +1405,31 @@ impl Client {
///
/// Returns the old proxies.
#[inline]
- pub fn set_proxies(&mut self, proxies: impl Into>) -> Vec {
- let (inner, proxies) = self.apply_proxies(proxies);
- inner.set_proxies(proxies)
+ pub fn set_proxies(&mut self, proxies: impl Into>) {
+ self.apply_proxies(proxies, true);
}
/// Append the proxies to the client.
#[inline]
pub fn append_proxies(&mut self, proxies: impl Into>) {
- let (inner, proxies) = self.apply_proxies(proxies);
- inner.append_proxies(proxies);
- }
-
- /// Private helper to handle setting or appending proxies.
- fn apply_proxies(
- &mut self,
- proxies: impl Into>,
- ) -> (&mut HyperClient, Cow<'static, [Proxy]>) {
- let proxies = proxies.into();
- let inner = self.inner_mut();
- inner.proxies_maybe_http_auth = proxies.iter().any(|p| p.maybe_has_http_auth());
- (&mut inner.hyper, proxies)
+ self.apply_proxies(proxies, false);
}
/// Unset the proxies for this client.
#[inline]
pub fn unset_proxies(&mut self) {
- self.inner_mut().hyper.clear_proxies();
+ self.inner_mut().proxies.clear();
+ }
+
+ /// Private helper to handle setting or appending proxies.
+ fn apply_proxies(&mut self, proxies: impl Into>, r#override: bool) {
+ let inner = self.inner_mut();
+ let proxies = proxies.into();
+ inner.proxies_maybe_http_auth = proxies.iter().any(|p| p.maybe_has_http_auth());
+ if r#override {
+ inner.proxies.clear();
+ }
+ inner.proxies.extend(proxies.into_owned());
}
/// Set that all sockets are bound to the configured address before connection.
@@ -1450,23 +1442,28 @@ impl Client {
where
T: Into