Skip to content

Commit caf9236

Browse files
feat: honor standard HTTP_PROXY env vars
1 parent f324d3a commit caf9236

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

api-client/src/lib.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,29 @@ impl ShuttleApiClient {
5151
timeout: Option<u64>,
5252
) -> Self {
5353
let mut builder = reqwest::Client::builder();
54-
if let Some(h) = headers {
55-
builder = builder.default_headers(h);
54+
55+
if let Ok(proxy) = std::env::var("HTTP_PROXY") {
56+
builder = builder.proxy(reqwest::Proxy::http(proxy).unwrap());
57+
}
58+
59+
if let Ok(proxy) = std::env::var("HTTPS_PROXY") {
60+
builder = builder.proxy(reqwest::Proxy::https(proxy).unwrap());
61+
}
62+
63+
if let Some(headers) = headers {
64+
builder = builder.default_headers(headers);
5665
}
66+
5767
let client = builder
5868
.timeout(Duration::from_secs(timeout.unwrap_or(60)))
5969
.build()
6070
.unwrap();
6171

6272
let builder = reqwest_middleware::ClientBuilder::new(client);
73+
6374
#[cfg(feature = "tracing")]
6475
let builder = builder.with(LoggingMiddleware);
76+
6577
let client = builder.build();
6678

6779
Self {

0 commit comments

Comments
 (0)