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:
parent
c7331b41e9
commit
0a9d50bf01
4 changed files with 154 additions and 106 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue