Skip to content

Use reqwest instead of ureq for download #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bitcoin_hashes = "0.11"
filetime = "0.2"
flate2 = "1.0"
tar = "0.4"
ureq = "2.5.0"
reqwest = { version = "0.10", features = ["blocking"] }
zip = "0.6"
time = "=0.3.10" # otherwise rust 1.57 fails to select time "^0.3.7"

Expand Down
10 changes: 4 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin_hashes::{sha256, Hash};
use flate2::read::GzDecoder;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Cursor, Read};
use std::io::{self, BufRead, BufReader, Cursor};
use std::path::Path;
use std::str::FromStr;
use tar::Archive;
Expand Down Expand Up @@ -103,13 +103,11 @@ fn main() {
);
println!("url:{}", url);
let mut downloaded_bytes = Vec::new();
let resp = ureq::get(&url).call().unwrap();
let mut resp =
reqwest::blocking::get(&url).expect(&format!("fetched bitcoin core from {}", url));
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);
let _size = resp.copy_to(&mut downloaded_bytes).unwrap();

let _size = resp
.into_reader()
.read_to_end(&mut downloaded_bytes)
.unwrap();
let downloaded_hash = sha256::Hash::hash(&downloaded_bytes);
assert_eq!(expected_hash, downloaded_hash);

Expand Down