Skip to content

Commit 2b95f70

Browse files
committed
Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set.
closes rust-bitcoin#48
1 parent 493c0f4 commit 2b95f70

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ home = "0.5.3" # use same ver in build-dep
1818
env_logger = "0.8"
1919

2020
[build-dependencies]
21-
ureq = "1.0" # allows to keep MSRV 1.41.1
21+
ureq = "2.1"
2222
bitcoin_hashes = "0.10"
2323
flate2 = "1.0"
2424
tar = "0.4"

build.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,18 @@ fn main() {
7373
);
7474
let mut downloaded_bytes = Vec::new();
7575

76-
let _size = ureq::get(&url)
76+
let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY"));
77+
let agent = if let Ok(proxy) = http_proxy {
78+
let proxy = ureq::Proxy::new(proxy).unwrap();
79+
ureq::AgentBuilder::new().proxy(proxy).build()
80+
} else {
81+
ureq::AgentBuilder::new().build()
82+
};
83+
84+
let _size = agent
85+
.get(&url)
7786
.call()
87+
.unwrap()
7888
.into_reader()
7989
.read_to_end(&mut downloaded_bytes)
8090
.unwrap();

0 commit comments

Comments
 (0)