fix: typo

This commit is contained in:
Nicolas Pernoud 2022-11-03 17:49:49 +01:00
parent 8dc6024395
commit f310dbb5de
2 changed files with 22 additions and 3 deletions

View File

@ -23,7 +23,7 @@ name="internal"
harness = false harness = false
[dependencies] [dependencies]
hyper = { version = "0.14.18", features = ["client"] } hyper = { version = "0.14.20", features = ["client"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
tokio = { version = "1.17.0", features = ["io-util", "rt"] } tokio = { version = "1.17.0", features = ["io-util", "rt"] }
tracing = "0.1.34" tracing = "0.1.34"

View File

@ -256,12 +256,12 @@ fn create_proxied_request<B>(
// Add forwarding information in the headers // Add forwarding information in the headers
match request.headers_mut().entry(&*X_FORWARDED_FOR) { match request.headers_mut().entry(&*X_FORWARDED_FOR) {
hyper::header::Entry::Vacant(entry) => { 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()?); entry.insert(client_ip.to_string().parse()?);
} }
hyper::header::Entry::Occupied(entry) => { 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 client_ip_str = client_ip.to_string();
let mut addr = let mut addr =
String::with_capacity(entry.get().as_bytes().len() + 2 + client_ip_str.len()); 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,
request_upgrade_type.as_ref(), 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?; let mut response = client.request(proxied_request).await?;
if response.status() == StatusCode::SWITCHING_PROTOCOLS { if response.status() == StatusCode::SWITCHING_PROTOCOLS {