add proxy authorization
This commit is contained in:
@@ -7,7 +7,7 @@ use futures::{Async, Future, Poll};
|
||||
use hyper::client::{Connect, FutureResponse, HttpConnector};
|
||||
use hyper::header::{Headers, Location, Referer, UserAgent, Accept, Encoding,
|
||||
AcceptEncoding, Range, qitem};
|
||||
use hyper_proxy::Intercept;
|
||||
use hyper_proxy::Proxy as HyperProxy;
|
||||
use hyper_tls::HttpsConnector;
|
||||
use native_tls::{TlsConnector, TlsConnectorBuilder};
|
||||
use tokio_core::reactor::Handle;
|
||||
@@ -129,8 +129,7 @@ impl ClientBuilder {
|
||||
if !config.hostname_verification {
|
||||
https_connector.danger_disable_hostname_verification(true);
|
||||
}
|
||||
let intercept = config.proxy.inner.intercept().clone();
|
||||
let mut connector = config.proxy.inner.with_connector(https_connector);
|
||||
let mut connector = config.proxy.inner.clone().with_connector(https_connector);
|
||||
let tls = try_!(config.tls.build());
|
||||
connector.set_tls(Some(tls));
|
||||
|
||||
@@ -142,7 +141,7 @@ impl ClientBuilder {
|
||||
inner: Arc::new(ClientRef {
|
||||
gzip: config.gzip,
|
||||
hyper: hyper_client,
|
||||
intercept: intercept,
|
||||
proxy: config.proxy.inner,
|
||||
headers: config.headers,
|
||||
redirect_policy: config.redirect_policy,
|
||||
referer: config.referer,
|
||||
@@ -415,8 +414,9 @@ impl Client {
|
||||
reusable
|
||||
});
|
||||
|
||||
if self.inner.intercept.matches(&uri) && uri.scheme() == Some("http") {
|
||||
if self.inner.proxy.intercept().matches(&uri) && uri.scheme() == Some("http") {
|
||||
req.set_proxy(true);
|
||||
req.headers_mut().extend(self.inner.proxy.headers().iter());
|
||||
}
|
||||
let in_flight = self.inner.hyper.request(req);
|
||||
|
||||
@@ -457,7 +457,7 @@ impl fmt::Debug for ClientBuilder {
|
||||
struct ClientRef {
|
||||
gzip: bool,
|
||||
headers: Headers,
|
||||
intercept: Intercept,
|
||||
proxy: HyperProxy<()>,
|
||||
hyper: HyperClient,
|
||||
redirect_policy: RedirectPolicy,
|
||||
referer: bool,
|
||||
@@ -556,8 +556,9 @@ impl Future for PendingRequest {
|
||||
if let Some(Some(ref body)) = self.body {
|
||||
req.set_body(body.clone());
|
||||
}
|
||||
if self.client.intercept.matches(&uri) && uri.scheme() == Some("http") {
|
||||
if self.client.proxy.intercept().matches(&uri) && uri.scheme() == Some("http") {
|
||||
req.set_proxy(true);
|
||||
req.headers_mut().extend(self.client.proxy.headers().iter());
|
||||
}
|
||||
self.in_flight = self.client.hyper.request(req);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user