diff options
-rw-r--r-- | src/reverse_proxy.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/reverse_proxy.rs b/src/reverse_proxy.rs index 82e7c7a..10f463c 100644 --- a/src/reverse_proxy.rs +++ b/src/reverse_proxy.rs @@ -48,7 +48,7 @@ fn remove_hop_headers(headers: &HeaderMap<HeaderValue>) -> HeaderMap<HeaderValue let mut result = HeaderMap::new(); for (k, v) in headers.iter() { if !is_hop_header(k.as_str()) { - result.insert(k.clone(), v.clone()); + result.append(k.clone(), v.clone()); } } result @@ -81,10 +81,10 @@ fn create_proxied_request<B>( // If request does not have host header, add it from original URI authority let host_header_name = "host"; - if let Some(authority) = request.uri().authority() { - if let hyper::header::Entry::Vacant(entry) = - builder.headers_mut().unwrap().entry(host_header_name) - { + if let hyper::header::Entry::Vacant(entry) = + builder.headers_mut().unwrap().entry(host_header_name) + { + if let Some(authority) = request.uri().authority() { entry.insert(authority.as_str().parse()?); } } @@ -111,6 +111,7 @@ fn create_proxied_request<B>( "https".try_into()?, ); + // Proxy upgrade requests properly if let Some(conn) = request.headers().get("connection") { if conn.to_str()?.to_lowercase() == "upgrade" { if let Some(upgrade) = request.headers().get("upgrade") { |