Skip to content

Commit

Permalink
HTTP proxy preserves headers' title case
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo authored and atkdef committed Sep 24, 2021
1 parent d826536 commit 3f9042c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/shadowsocks-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ socket2 = { version = "0.4", features = ["all"] }
libc = "0.2"

http = { version = "0.2", optional = true }
hyper = { version = "0.14", optional = true, features = ["full"] }
hyper = { version = "0.14.7", optional = true, features = ["full"] }
tower = { version = "0.4", optional = true }

trust-dns-resolver = { version = "0.20.1", optional = true, features = ["serde-config"] }
Expand Down
5 changes: 4 additions & 1 deletion crates/shadowsocks-service/src/local/http/client_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ impl ProxyClientCache {
}

// Create a new client
let client = Client::builder().build::<_, Body>(ProxyConnector::new(self.context.clone(), server.clone()));
let client = Client::builder()
.http1_preserve_header_case(true)
.http1_title_case_headers(true)
.build::<_, Body>(ProxyConnector::new(self.context.clone(), server.clone()));
cache.insert(server_config.addr().clone(), client.clone());

client
Expand Down
7 changes: 6 additions & 1 deletion crates/shadowsocks-service/src/local/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ impl Http {

/// Run server
pub async fn run(self, client_config: &ServerAddr, balancer: PingBalancer) -> io::Result<()> {
let bypass_client = Client::builder().build::<_, Body>(BypassConnector::new(self.context.clone()));
let bypass_client = Client::builder()
.http1_preserve_header_case(true)
.http1_title_case_headers(true)
.build::<_, Body>(BypassConnector::new(self.context.clone()));

let context = self.context.clone();
let proxy_client_cache = self.proxy_client_cache.clone();
Expand Down Expand Up @@ -89,6 +92,8 @@ impl Http {
let server = match bind_result {
Ok(builder) => builder
.http1_only(true)
.http1_preserve_header_case(true)
.http1_title_case_headers(true)
.tcp_sleep_on_accept_errors(true)
.serve(make_service),
Err(err) => {
Expand Down

0 comments on commit 3f9042c

Please sign in to comment.