diff --git a/Cargo.toml b/Cargo.toml index 5abff50..b1ac29b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ name="internal" harness = false [dependencies] -hyper = { version = "0.14.18", features = ["client"] } +hyper = { version = "0.14.20", features = ["client"] } lazy_static = "1.4.0" tokio = { version = "1.17.0", features = ["io-util", "rt"] } tracing = "0.1.34" diff --git a/src/lib.rs b/src/lib.rs index e2275d6..d46ccf9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -256,12 +256,12 @@ fn create_proxied_request( // Add forwarding information in the headers match request.headers_mut().entry(&*X_FORWARDED_FOR) { hyper::header::Entry::Vacant(entry) => { - debug!("X-Fowraded-for header was vacant"); + debug!("X-Forwarded-For header was vacant"); entry.insert(client_ip.to_string().parse()?); } hyper::header::Entry::Occupied(entry) => { - debug!("X-Fowraded-for header was occupied"); + debug!("X-Forwarded-For header was occupied"); let client_ip_str = client_ip.to_string(); let mut addr = String::with_capacity(entry.get().as_bytes().len() + 2 + client_ip_str.len()); @@ -300,6 +300,25 @@ pub async fn call<'a, T: hyper::client::connect::Connect + Clone + Send + Sync + request, request_upgrade_type.as_ref(), )?; + + ////////////////////////////////////////////// + // UNCOMMENT THIS FOR FULL REQUEST LOGGING // + //////////////////////////////////////////// + /* + let (parts, body) = proxied_request.into_parts(); + debug!( + "proxied request = {} {} {:?}", + parts.method, + parts.uri, + parts.headers + ); + let bytes = hyper::body::to_bytes(body).await.expect("could not get body data"); + if let Ok(body) = std::str::from_utf8(&bytes) { + debug!("proxied request body = {:?}", body); + //std::fs::write("./request_body.xml", body).expect("Unable to write file"); + } + let proxied_request = Request::from_parts(parts, Body::from(bytes)); + */ let mut response = client.request(proxied_request).await?; if response.status() == StatusCode::SWITCHING_PROTOCOLS {