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 24, 2023
1 parent e7a2b6c commit aae9db7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,19 @@ mod download {
);
println!("url:{}", url);
let mut downloaded_bytes = Vec::new();
let resp = ureq::get(&url).call().unwrap();
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 aae9db7

Please sign in to comment.