aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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());