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:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user