Skip to content

Commit 282212f

Browse files
committed
Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set.
closes #48
1 parent e7a2b6c commit 282212f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,16 @@ mod download {
114114
);
115115
println!("url:{}", url);
116116
let mut downloaded_bytes = Vec::new();
117-
let resp = ureq::get(&url).call().unwrap();
117+
118+
let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY"));
119+
let agent = if let Ok(proxy) = http_proxy {
120+
let proxy = ureq::Proxy::new(proxy).unwrap();
121+
ureq::AgentBuilder::new().proxy(proxy).build()
122+
} else {
123+
ureq::AgentBuilder::new().build()
124+
};
125+
126+
let resp = agent.get(&url).call().unwrap();
118127
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);
119128

120129
let _size = resp

0 commit comments

Comments
 (0)