Skip to content

Commit bae8032

Browse files
committed
Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set.
closes #29
1 parent 706d8af commit bae8032

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ fn main() {
4545
let url = format!("{}/{}", GITHUB_URL, download_filename);
4646
let mut downloaded_bytes = Vec::new();
4747

48-
let _size = ureq::get(&url)
48+
let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY"));
49+
let agent = if let Ok(proxy) = http_proxy {
50+
let proxy = ureq::Proxy::new(proxy).unwrap();
51+
ureq::AgentBuilder::new()
52+
.proxy(proxy)
53+
.build()
54+
} else {
55+
ureq::AgentBuilder::new().build()
56+
};
57+
58+
let _size = agent.get(&url)
4959
.call()
5060
.unwrap()
5161
.into_reader()

0 commit comments

Comments
 (0)