aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-09 11:20:04 +0100
committerAlex Auvolat <alex@adnab.me>2021-12-09 11:20:04 +0100
commit8153bdca4618eed76665eeb4c5a005378701df1f (patch)
treef1c895ffd7e69a8841fc6ad0bad962670f5981a2 /src
parent207f467b879194c993c70a092c232daca8ad1057 (diff)
downloadtricot-8153bdca4618eed76665eeb4c5a005378701df1f.tar.gz
tricot-8153bdca4618eed76665eeb4c5a005378701df1f.zip
Fix multiple header occurences
Diffstat (limited to 'src')
-rw-r--r--src/reverse_proxy.rs11
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") {