Skip to content

Commit 09fb8d2

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 4c3af5c commit 09fb8d2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
strategy:
7373
fail-fast: false
7474
matrix:
75-
toolchain: [ "1.41.1", "stable", "nightly" ]
75+
toolchain: [ "1.42", "stable", "nightly" ]
7676

7777
steps:
7878
- uses: actions/checkout@v2

Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ env_logger = "0.8"
1919

2020
[build-dependencies]
2121
bitcoin_hashes = "0.11"
22+
ureq = "2.1"
23+
flate2 = "1.0"
2224
tar = "0.4"
2325
zip = "0.5"
24-
25-
# allows to keep MSRV 1.41.1
26-
ureq = "1.0"
2726
filetime = "=0.2.15"
28-
flate2 = "=1.0.22"
2927

3028
[features]
3129
"23_0" = []

build.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,19 @@ fn main() {
103103
);
104104
println!("url:{}", url);
105105
let mut downloaded_bytes = Vec::new();
106-
let resp = ureq::get(&url).call();
107-
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);
108106

109-
let _size = resp
107+
let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY"));
108+
let agent = if let Ok(proxy) = http_proxy {
109+
let proxy = ureq::Proxy::new(proxy).unwrap();
110+
ureq::AgentBuilder::new().proxy(proxy).build()
111+
} else {
112+
ureq::AgentBuilder::new().build()
113+
};
114+
115+
let _size = agent
116+
.get(&url)
117+
.call()
118+
.unwrap()
110119
.into_reader()
111120
.read_to_end(&mut downloaded_bytes)
112121
.unwrap();

0 commit comments

Comments
 (0)