Use reqwest instead of curl to download libwebrtc (#44)
* use reqwest instead of curl to download libwebrtc curl crate fails 2/3 computers I use when not configured. Make everything simpler for users * Update Cargo.lock
This commit is contained in:
@@ -12,7 +12,7 @@ cxx = "1.0"
|
||||
log = "0.4"
|
||||
|
||||
[build-dependencies]
|
||||
curl = "0.4"
|
||||
reqwest = { version = "0.11", features = ["blocking", "json"] }
|
||||
tar = "0.4"
|
||||
flate2 = "1.0"
|
||||
cxx-build = "1.0"
|
||||
@@ -21,7 +21,7 @@ regex = "1.0"
|
||||
zip = "0.6.3"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.9"
|
||||
env_logger = "0.10"
|
||||
|
||||
#[lib]
|
||||
#crate-type = ["staticlib", "cdylib"]
|
||||
|
||||
+3
-15
@@ -1,4 +1,3 @@
|
||||
use curl::easy::Easy;
|
||||
use flate2::read::GzDecoder;
|
||||
use regex::Regex;
|
||||
use std::env;
|
||||
@@ -41,21 +40,10 @@ fn download_prebuilt(
|
||||
if !file_path.exists() {
|
||||
let file = fs::File::create(&file_path)?;
|
||||
{
|
||||
// Download WebRTC-SDK
|
||||
let mut writer = io::BufWriter::new(file);
|
||||
let mut handle = Easy::new();
|
||||
handle.url(&file_url)?;
|
||||
handle.follow_location(true)?;
|
||||
handle.write_function(move |data| Ok(writer.write(data).unwrap()))?;
|
||||
handle.perform()?;
|
||||
|
||||
let response_code = handle.response_code()?;
|
||||
if response_code != 200 {
|
||||
fs::remove_file(&file_path)?;
|
||||
Err(format!(
|
||||
"Failed to download WebRTC-SDK (Status: {}) {}",
|
||||
response_code, file_url
|
||||
))?
|
||||
}
|
||||
let mut res = reqwest::blocking::get(&file_url)?;
|
||||
io::copy(&mut res, &mut writer)?;
|
||||
}
|
||||
|
||||
// Extract the archive
|
||||
|
||||
Reference in New Issue
Block a user