From 82786d44619e1b79f7a2c3568c54f7388ccca8f4 Mon Sep 17 00:00:00 2001 From: Arve Seljebu Date: Mon, 1 Jul 2019 06:02:51 +0200 Subject: [PATCH] Full proxy omit content length (#152) * omit content-length header in http-full-proxy * cargo fmt --- http-full-proxy/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/http-full-proxy/src/main.rs b/http-full-proxy/src/main.rs index bcb788c3..a68b46f1 100644 --- a/http-full-proxy/src/main.rs +++ b/http-full-proxy/src/main.rs @@ -15,7 +15,9 @@ fn forward( new_url.set_path(req.uri().path()); new_url.set_query(req.uri().query()); - let forwarded_req = client.request_from(new_url.as_str(), req.head()).no_decompress(); + let forwarded_req = client + .request_from(new_url.as_str(), req.head()) + .no_decompress(); let forwarded_req = if let Some(addr) = req.head().peer_addr { forwarded_req.header("x-forwarded-for", format!("{}", addr.ip())) } else { @@ -27,8 +29,10 @@ fn forward( .map_err(Error::from) .map(|res| { let mut client_resp = HttpResponse::build(res.status()); - for (header_name, header_value) in - res.headers().iter().filter(|(h, _)| *h != "connection") + for (header_name, header_value) in res + .headers() + .iter() + .filter(|(h, _)| *h != "connection" && *h != "content-length") { client_resp.header(header_name.clone(), header_value.clone()); }