Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect proxy env vars #4624

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/wasix/src/http/reqwest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Duration;
use std::{env, time::Duration};

use anyhow::Context;
use futures::{future::BoxFuture, TryStreamExt};
Expand Down Expand Up @@ -44,10 +44,14 @@ impl ReqwestHttpClient {
// TODO: use persistent client?
let client = {
let _guard = Handle::try_current().map_err(|_| self.handle.enter());
reqwest::Client::builder()
.connect_timeout(self.connect_timeout)
.build()
.context("Could not create reqwest client")?
let mut builder = reqwest::Client::builder().connect_timeout(self.connect_timeout);

let proxy = env::var("http_proxy").or_else(|_| env::var("HTTP_PROXY"));
if let Ok(scheme) = proxy {
builder = builder.proxy(reqwest::Proxy::all(scheme)?);
}

builder.build().context("Could not create reqwest client")?
};

let mut builder = client.request(method, request.url.as_str());
Expand Down
Loading