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 rust-bitcoin#48
  • Loading branch information
ulrichard committed Sep 29, 2022
1 parent 4c3af5c commit 09fb8d2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [ "1.41.1", "stable", "nightly" ]
toolchain: [ "1.42", "stable", "nightly" ]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ env_logger = "0.8"

[build-dependencies]
bitcoin_hashes = "0.11"
ureq = "2.1"
flate2 = "1.0"
tar = "0.4"
zip = "0.5"

# allows to keep MSRV 1.41.1
ureq = "1.0"
filetime = "=0.2.15"
flate2 = "=1.0.22"

[features]
"23_0" = []
Expand Down
15 changes: 12 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,19 @@ fn main() {
);
println!("url:{}", url);
let mut downloaded_bytes = Vec::new();
let resp = ureq::get(&url).call();
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);

let _size = resp
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 09fb8d2

Please sign in to comment.