Skip to content

Commit

Permalink
respect proxy env vars (#4624)
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej authored Apr 29, 2024
2 parents 08126b6 + 51ffef9 commit 0d4e3db
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 0d4e3db

Please sign in to comment.