Improve debug logging (#781)
This commit is contained in:
@@ -1189,13 +1189,13 @@ impl Future for PendingRequest {
|
||||
|
||||
match action {
|
||||
redirect::ActionKind::Follow => {
|
||||
debug!("redirecting '{}' to '{}'", self.url, loc);
|
||||
self.url = loc;
|
||||
|
||||
let mut headers =
|
||||
std::mem::replace(self.as_mut().headers(), HeaderMap::new());
|
||||
|
||||
remove_sensitive_headers(&mut headers, &self.url, &self.urls);
|
||||
debug!("redirecting to {:?} '{}'", self.method, self.url);
|
||||
let uri = expect_uri(&self.url);
|
||||
let body = match self.body {
|
||||
Some(Some(ref body)) => Body::reusable(body.clone()),
|
||||
@@ -1224,7 +1224,7 @@ impl Future for PendingRequest {
|
||||
continue;
|
||||
}
|
||||
redirect::ActionKind::Stop => {
|
||||
debug!("redirect_policy disallowed redirection to '{}'", loc);
|
||||
debug!("redirect policy disallowed redirection to '{}'", loc);
|
||||
}
|
||||
redirect::ActionKind::Error(err) => {
|
||||
return Poll::Ready(Err(crate::error::redirect(
|
||||
@@ -1235,6 +1235,8 @@ impl Future for PendingRequest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug!("response '{}' for {}", res.status(), self.url);
|
||||
let res = Response::new(res, self.url.clone(), self.client.gzip, self.timeout.take());
|
||||
return Poll::Ready(Ok(res));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use http;
|
||||
use hyper::client::connect::HttpInfo;
|
||||
use hyper::header::CONTENT_LENGTH;
|
||||
use hyper::{HeaderMap, StatusCode, Version};
|
||||
use log::debug;
|
||||
use mime::Mime;
|
||||
#[cfg(feature = "json")]
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -50,7 +49,6 @@ impl Response {
|
||||
let mut headers = parts.headers;
|
||||
let decoder = Decoder::detect(&mut headers, Body::response(body, timeout), gzip);
|
||||
|
||||
debug!("Response: '{}' for {}", status, url);
|
||||
Response {
|
||||
status,
|
||||
headers,
|
||||
|
||||
@@ -293,7 +293,7 @@ impl Connector {
|
||||
dst: Uri,
|
||||
proxy_scheme: ProxyScheme,
|
||||
) -> Result<Conn, BoxError> {
|
||||
log::trace!("proxy({:?}) intercepts {:?}", proxy_scheme, dst);
|
||||
log::debug!("proxy({:?}) intercepts '{:?}'", proxy_scheme, dst);
|
||||
|
||||
let (proxy_dst, _auth) = match proxy_scheme {
|
||||
ProxyScheme::Http { host, auth } => (into_uri(Scheme::HTTP, host), auth),
|
||||
@@ -421,8 +421,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Service<Uri> for Connector
|
||||
{
|
||||
impl Service<Uri> for Connector {
|
||||
type Response = Conn;
|
||||
type Error = BoxError;
|
||||
type Future = Connecting;
|
||||
@@ -432,6 +431,7 @@ impl Service<Uri> for Connector
|
||||
}
|
||||
|
||||
fn call(&mut self, dst: Uri) -> Self::Future {
|
||||
log::debug!("starting new connection: {:?}", dst);
|
||||
let timeout = self.timeout;
|
||||
for prox in self.proxies.iter() {
|
||||
if let Some(proxy_scheme) = prox.intercept(&dst) {
|
||||
|
||||
34
src/proxy.rs
34
src/proxy.rs
@@ -55,7 +55,7 @@ pub struct Proxy {
|
||||
/// A particular scheme used for proxying requests.
|
||||
///
|
||||
/// For example, HTTP vs SOCKS5
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone)]
|
||||
pub enum ProxyScheme {
|
||||
Http {
|
||||
auth: Option<HeaderValue>,
|
||||
@@ -434,6 +434,38 @@ impl ProxyScheme {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ProxyScheme {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
ProxyScheme::Http {
|
||||
auth: _auth,
|
||||
host,
|
||||
} => {
|
||||
write!(f, "http://{}", host)
|
||||
},
|
||||
ProxyScheme::Https {
|
||||
auth: _auth,
|
||||
host,
|
||||
} => {
|
||||
write!(f, "https://{}", host)
|
||||
},
|
||||
#[cfg(feature = "socks")]
|
||||
ProxyScheme::Socks5 {
|
||||
addr,
|
||||
auth: _auth,
|
||||
remote_dns,
|
||||
} => {
|
||||
let h = if *remote_dns {
|
||||
"h"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
write!(f, "socks5{}://{}", h, addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type SystemProxyMap = HashMap<String, ProxyScheme>;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user