From 6c6b8dbc89d7b092cd8b9418a81944ba13b01998 Mon Sep 17 00:00:00 2001 From: amr-crabnebula Date: Wed, 18 Oct 2023 04:10:41 +0300 Subject: [PATCH] fix: read proxy when downloading resources Port of https://github.com/tauri-apps/tauri/pull/8012 Co-authored-by: Caijinglong --- .changes/http_proxy.md | 5 +++++ Cargo.lock | 2 +- crates/packager/src/util.rs | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) 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/Cargo.lock b/Cargo.lock index 72b37c9d..c181c124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -740,7 +740,7 @@ dependencies = [ [[package]] name = "cargo-packager" -version = "0.1.2" +version = "0.2.0" dependencies = [ "ar", "base64 0.21.4", 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)