Skip to content

Commit

Permalink
fix(proxy): Ignore case of WS upgrade type (#974) (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwxxhdb authored Nov 6, 2024
1 parent 73463d2 commit 93ca71f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/proxy/src/hyper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/proxy/src/reqwest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93ca71f

Please sign in to comment.