http: Refactor construction of HTTP clients with a proxy (#14911)

This PR refactors the `http` crate to expose a better way of
constructing an `HttpClient` that contains a proxy.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-21 10:15:38 -04:00 committed by GitHub
parent c7331b41e9
commit 0a9d50bf01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 154 additions and 106 deletions

View file

@ -269,7 +269,16 @@ impl NodeRuntime for RealNodeRuntime {
}
if let Some(proxy) = self.http.proxy() {
command.args(["--proxy", proxy]);
// Map proxy settings from `http://localhost:10809` to `http://127.0.0.1:10809`
// NodeRuntime without environment information can not parse `localhost`
// correctly.
// TODO: map to `[::1]` if we are using ipv6
let proxy = proxy
.to_string()
.to_ascii_lowercase()
.replace("localhost", "127.0.0.1");
command.args(["--proxy", &proxy]);
}
#[cfg(windows)]