From 93ca71fffd5537829c796c4fb007be350028da9f Mon Sep 17 00:00:00 2001 From: mwxxhdb Date: Wed, 6 Nov 2024 12:29:23 +0800 Subject: [PATCH] fix(proxy): Ignore case of WS upgrade type (#974) (#976) --- crates/proxy/src/hyper_client.rs | 4 ++-- crates/proxy/src/reqwest_client.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/proxy/src/hyper_client.rs b/crates/proxy/src/hyper_client.rs index db2f5ea0f..e76b0d06c 100644 --- a/crates/proxy/src/hyper_client.rs +++ b/crates/proxy/src/hyper_client.rs @@ -7,7 +7,7 @@ use salvo_core::rt::tokio::TokioIo; use salvo_core::Error; use tokio::io::copy_bidirectional; -use crate::{Client, HyperRequest,Proxy, BoxedError, Upstreams,HyperResponse}; +use crate::{Client, HyperRequest, Proxy, BoxedError, Upstreams, HyperResponse}; /// A [`Client`] implementation based on [`hyper_util::client::legacy::Client`]. #[derive(Clone, Debug)] @@ -61,7 +61,7 @@ impl Client for HyperClient { if response.status() == StatusCode::SWITCHING_PROTOCOLS { let response_upgrade_type = crate::get_upgrade_type(response.headers()); - if request_upgrade_type.as_deref() == response_upgrade_type { + if request_upgrade_type == response_upgrade_type.map(|s| s.to_lowercase()) { let response_upgraded = hyper::upgrade::on(&mut response).await?; if let Some(request_upgraded) = request_upgraded { tokio::spawn(async move { diff --git a/crates/proxy/src/reqwest_client.rs b/crates/proxy/src/reqwest_client.rs index 52894669c..b3ba2448c 100644 --- a/crates/proxy/src/reqwest_client.rs +++ b/crates/proxy/src/reqwest_client.rs @@ -58,7 +58,7 @@ impl Client for ReqwestClient { let mut hyper_response = if response.status() == StatusCode::SWITCHING_PROTOCOLS { let response_upgrade_type = crate::get_upgrade_type(response.headers()); - if request_upgrade_type.as_deref() == response_upgrade_type { + if request_upgrade_type == response_upgrade_type.map(|s| s.to_lowercase()) { let mut response_upgraded = response .upgrade() .await