Fix multiple header occurences

This commit is contained in:
Alex 2021-12-09 11:20:04 +01:00
parent 207f467b87
commit 8153bdca46
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1

View file

@ -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") {