From 7e03988cafeac89b6e6c67c69c3f8f40cf943af9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 14 Feb 2019 13:28:41 +0100 Subject: [PATCH] avoid double logging of proxied requests --- src/server/rest.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server/rest.rs b/src/server/rest.rs index e94b7f4a..efd49cd5 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -59,7 +59,11 @@ pub struct ApiService { impl ApiService { fn log_response(path: &str, resp: &Response) { + + if resp.headers().contains_key("PBS_PROXIED") { return; } + let status = resp.status(); + if !status.is_success() { let reason = status.canonical_reason().unwrap_or("unknown reason"); let client = "unknown"; // fixme: howto get peer_addr ? @@ -169,7 +173,11 @@ fn proxy_protected_request( let resp = hyper::client::Client::new() .request(request) - .map_err(|e| Error::from(e)); + .map_err(|e| Error::from(e)) + .map(|mut resp| { + resp.headers_mut().insert("PBS_PROXIED", header::HeaderValue::from_static("1")); + resp + }); let resp = if info.reload_timezone { Either::A(resp.then(|resp| {unsafe { tzset() }; resp }))