avoid double logging of proxied requests

This commit is contained in:
Dietmar Maurer 2019-02-14 13:28:41 +01:00
parent af6f80d3db
commit 7e03988caf

View File

@ -59,7 +59,11 @@ pub struct ApiService {
impl ApiService { impl ApiService {
fn log_response(path: &str, resp: &Response<Body>) { fn log_response(path: &str, resp: &Response<Body>) {
if resp.headers().contains_key("PBS_PROXIED") { return; }
let status = resp.status(); let status = resp.status();
if !status.is_success() { if !status.is_success() {
let reason = status.canonical_reason().unwrap_or("unknown reason"); let reason = status.canonical_reason().unwrap_or("unknown reason");
let client = "unknown"; // fixme: howto get peer_addr ? let client = "unknown"; // fixme: howto get peer_addr ?
@ -169,7 +173,11 @@ fn proxy_protected_request(
let resp = hyper::client::Client::new() let resp = hyper::client::Client::new()
.request(request) .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 { let resp = if info.reload_timezone {
Either::A(resp.then(|resp| {unsafe { tzset() }; resp })) Either::A(resp.then(|resp| {unsafe { tzset() }; resp }))