Skip to content

Commit

Permalink
chore: refactor http_client.rs to support https-tunnel feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arloor committed Sep 5, 2024
1 parent e244628 commit 82ce21b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/shadowsocks-service/src/local/http/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,26 @@ where
}
}

#[cfg(not(feature = "https-tunnel"))]
#[inline]
pub async fn send_request(&mut self, req: Request<B>) -> hyper::Result<Response<body::Incoming>> {
match self {
HttpConnection::Http1(r, _) => r.send_request(req).await,
HttpConnection::Http2(r, _) => r.send_request(req).await,
}
}

#[cfg(feature = "https-tunnel")]
#[inline]
pub async fn send_request(&mut self, mut req: Request<B>) -> hyper::Result<Response<body::Incoming>> {
match self {
HttpConnection::Http1(r, auth) => {
#[cfg(feature = "https-tunnel")]
if let Some(auth) = &auth {
req.headers_mut().insert("Proxy-Authorization", auth.0.parse().unwrap());
}
r.send_request(req).await
}
HttpConnection::Http2(r, auth) => {
#[cfg(feature = "https-tunnel")]
if let Some(auth) = &auth {
req.headers_mut().insert("Proxy-Authorization", auth.0.parse().unwrap());
}
Expand Down

0 comments on commit 82ce21b

Please sign in to comment.