Skip to content

Commit 3ad6e02

Browse files
authored
refactor: remove internal proxy sys cache (#2442)
This removes some cache code that would only check for system proxies one time. Now it will check every time a `Client` is built. Technically, removes the crate feature `__internal_proxy_sys_no_cache`, but that was unstable and you weren't using it, right? Closes #2441
1 parent 95fec09 commit 3ad6e02

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,12 @@ jobs:
9191

9292
include:
9393
- name: linux / stable
94-
test-features: "--features __internal_proxy_sys_no_cache"
9594
- name: linux / beta
9695
rust: beta
97-
test-features: "--features __internal_proxy_sys_no_cache"
9896
# - name: linux / nightly
9997
# rust: nightly
100-
# test-features: "--features __internal_proxy_sys_no_cache"
10198
- name: macOS / stable
10299
os: macOS-latest
103-
test-features: "--features __internal_proxy_sys_no_cache"
104100

105101
- name: windows / stable-x86_64-msvc
106102
os: windows-latest
@@ -272,7 +268,7 @@ jobs:
272268
run: |
273269
cargo clean
274270
cargo update -Z minimal-versions
275-
cargo update -p proc-macro2 --precise 1.0.62
271+
cargo update -p proc-macro2 --precise 1.0.87
276272
cargo check
277273
cargo check --all-features
278274

src/proxy.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::into_url::{IntoUrl, IntoUrlSealed};
77
use crate::Url;
88
use http::{header::HeaderValue, Uri};
99
use ipnet::IpNet;
10-
use once_cell::sync::Lazy;
1110
use percent_encoding::percent_decode;
1211
use std::collections::HashMap;
1312
use std::env;
@@ -280,13 +279,9 @@ impl Proxy {
280279
}
281280

282281
pub(crate) fn system() -> Proxy {
283-
let mut proxy = if cfg!(feature = "__internal_proxy_sys_no_cache") {
284-
Proxy::new(Intercept::System(Arc::new(get_sys_proxies(
285-
get_from_platform(),
286-
))))
287-
} else {
288-
Proxy::new(Intercept::System(SYS_PROXIES.clone()))
289-
};
282+
let mut proxy = Proxy::new(Intercept::System(Arc::new(get_sys_proxies(
283+
get_from_platform(),
284+
))));
290285
proxy.no_proxy = NoProxy::from_env();
291286
proxy
292287
}
@@ -876,9 +871,6 @@ impl Dst for Uri {
876871
}
877872
}
878873

879-
static SYS_PROXIES: Lazy<Arc<SystemProxyMap>> =
880-
Lazy::new(|| Arc::new(get_sys_proxies(get_from_platform())));
881-
882874
/// Get system proxies information.
883875
///
884876
/// All platforms will check for proxy settings via environment variables.

tests/proxy.rs

-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ async fn test_no_proxy() {
163163
assert_eq!(res.status(), reqwest::StatusCode::OK);
164164
}
165165

166-
#[cfg_attr(not(feature = "__internal_proxy_sys_no_cache"), ignore)]
167166
#[tokio::test]
168167
async fn test_using_system_proxy() {
169168
let url = "http://not.a.real.sub.hyper.rs/prox";
@@ -175,9 +174,6 @@ async fn test_using_system_proxy() {
175174
async { http::Response::default() }
176175
});
177176

178-
// Note: we're relying on the `__internal_proxy_sys_no_cache` feature to
179-
// check the environment every time.
180-
181177
// save system setting first.
182178
let system_proxy = env::var("http_proxy");
183179
// set-up http proxy.

0 commit comments

Comments
 (0)