aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-06 12:34:19 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-06 12:34:19 +0200
commitdf4a36990c799901463d63c78de0f0672b675688 (patch)
treefa27c43cf37412ae124a55db1b499e6c193d03cb
parent8c6114c3d306acebca908f37861e2c03d8562032 (diff)
downloadtricot-df4a36990c799901463d63c78de0f0672b675688.tar.gz
tricot-df4a36990c799901463d63c78de0f0672b675688.zip
Try again to fix connection: upgrade bugdocker-39
-rw-r--r--src/reverse_proxy.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/reverse_proxy.rs b/src/reverse_proxy.rs
index 99a7c98..dc45869 100644
--- a/src/reverse_proxy.rs
+++ b/src/reverse_proxy.rs
@@ -52,8 +52,12 @@ fn copy_upgrade_headers(
old_headers: &HeaderMap<HeaderValue>,
new_headers: &mut HeaderMap<HeaderValue>,
) -> Result<()> {
+ // The Connection header is stripped as it is a hop header that we are not supposed to proxy.
+ // However, it might also contain an Upgrade directive, e.g. for Websockets:
+ // when that happen, we do want to preserve that directive.
if let Some(conn) = old_headers.get(header::CONNECTION) {
- if conn.to_str()?.to_lowercase() == "upgrade" {
+ let conn_str = conn.to_str()?.to_lowercase();
+ if conn_str.split(',').map(str::trim).any(|x| x == "upgrade") {
if let Some(upgrade) = old_headers.get(header::UPGRADE) {
new_headers.insert(header::CONNECTION, "Upgrade".try_into()?);
new_headers.insert(header::UPGRADE, upgrade.clone());