Skip to content

Commit

Permalink
Downloading the binaries through a proxy if either HTTPS_PROXY or HTT…
Browse files Browse the repository at this point in the history
…P_PROXY environment variable is set.

closes #48
  • Loading branch information
ulrichard committed Jan 26, 2022
1 parent 493c0f4 commit 2b95f70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ home = "0.5.3" # use same ver in build-dep
env_logger = "0.8"

[build-dependencies]
ureq = "1.0" # allows to keep MSRV 1.41.1
ureq = "2.1"
bitcoin_hashes = "0.10"
flate2 = "1.0"
tar = "0.4"
Expand Down
12 changes: 11 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ fn main() {
);
let mut downloaded_bytes = Vec::new();

let _size = ureq::get(&url)
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 _size = agent
.get(&url)
.call()
.unwrap()
.into_reader()
.read_to_end(&mut downloaded_bytes)
.unwrap();
Expand Down

0 comments on commit 2b95f70

Please sign in to comment.