From 282212ff4280b2f10442a2fabc77929b00dfa0c7 Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Wed, 26 Jan 2022 17:03:52 +0100 Subject: [PATCH] Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set. closes #48 --- build.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 2a8666f..917d40a 100644 --- a/build.rs +++ b/build.rs @@ -114,7 +114,16 @@ mod download { ); println!("url:{}", url); let mut downloaded_bytes = Vec::new(); - let resp = ureq::get(&url).call().unwrap(); + + let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY")); + let agent = if let Ok(proxy) = http_proxy { + let proxy = ureq::Proxy::new(proxy).unwrap(); + ureq::AgentBuilder::new().proxy(proxy).build() + } else { + ureq::AgentBuilder::new().build() + }; + + let resp = agent.get(&url).call().unwrap(); assert_eq!(resp.status(), 200, "url {} didn't return 200", url); let _size = resp