Skip to content

Commit

Permalink
Refactor build_upstream_req function to handle HTTP/2 and HTTPS corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
arloor committed Sep 17, 2024
1 parent b777ab5 commit 1d9a784
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions rust_http_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,23 +384,25 @@ fn build_upstream_req(
path_and_query
);

let mut builder =
Request::builder()
.method(method)
.uri(url.clone())
.version(if !url.starts_with("https:") {
match location_config.upstream.version {
reverse::Version::H1 => Version::HTTP_11,
reverse::Version::H2 => Version::HTTP_2,
reverse::Version::Auto => Version::HTTP_11,
}
} else {
match location_config.upstream.version {
reverse::Version::H1 => Version::HTTP_11,
reverse::Version::H2 => Version::HTTP_2,
reverse::Version::Auto => req.version(),
}
});
let mut builder = Request::builder().method(method).uri(url.clone()).version(
if !location_config
.upstream
.scheme_and_authority
.starts_with("https:")
{
match location_config.upstream.version {
reverse::Version::H1 => Version::HTTP_11,
reverse::Version::H2 => Version::HTTP_2,
reverse::Version::Auto => Version::HTTP_11,
}
} else {
match location_config.upstream.version {
reverse::Version::H1 => Version::HTTP_11,
reverse::Version::H2 => Version::HTTP_2,
reverse::Version::Auto => req.version(),
}
},
);
let header_map = match builder.headers_mut() {
Some(header_map) => header_map,
None => {
Expand Down

0 comments on commit 1d9a784

Please sign in to comment.