From 274a6bec553f273934347a18e0d6e2e1ec61bbeb Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 18 Oct 2023 05:12:54 +0300 Subject: [PATCH] fix: read proxy when downloading resources (#49) Port of https://github.com/tauri-apps/tauri/pull/8012 Co-authored-by: Caijinglong --- .changes/http_proxy.md | 5 +++++ crates/packager/src/util.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/http_proxy.md diff --git a/.changes/http_proxy.md b/.changes/http_proxy.md new file mode 100644 index 00000000..5c2a319c --- /dev/null +++ b/.changes/http_proxy.md @@ -0,0 +1,5 @@ +--- +"cargo-packager": patch +--- + +Read `HTTP_PROXY` env var when downloading resources. diff --git a/crates/packager/src/util.rs b/crates/packager/src/util.rs index 7120bbd9..458cdcc3 100644 --- a/crates/packager/src/util.rs +++ b/crates/packager/src/util.rs @@ -130,7 +130,8 @@ pub fn target_triple() -> crate::Result { pub(crate) fn download(url: &str) -> crate::Result> { tracing::info!("Downloading {}", url); - let response = ureq::get(url).call().map_err(Box::new)?; + let agent = ureq::AgentBuilder::new().try_proxy_from_env(true).build(); + let response = agent.get(url).call().map_err(Box::new)?; let mut bytes = Vec::new(); response.into_reader().read_to_end(&mut bytes)?; Ok(bytes)