diff options
author | Bastien Orivel <eijebong@bananium.fr> | 2019-06-13 23:18:01 +0200 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-06-13 21:18:01 +0000 |
commit | 6cd0f12efb7664bb99a4b79732b8f4f63e42b033 (patch) | |
tree | ef20bd136ddc14013711148fbc46c61f94e53396 /winpty | |
parent | b1dcd6b25276797ce0a0fea543d596e95bd7460f (diff) | |
download | alacritty-6cd0f12efb7664bb99a4b79732b8f4f63e42b033.tar.gz alacritty-6cd0f12efb7664bb99a4b79732b8f4f63e42b033.zip |
Remove reqwest dependency on Windows
Diffstat (limited to 'winpty')
-rw-r--r-- | winpty/Cargo.toml | 2 | ||||
-rw-r--r-- | winpty/build.rs | 19 |
2 files changed, 16 insertions, 5 deletions
diff --git a/winpty/Cargo.toml b/winpty/Cargo.toml index a8611c3d..f049013c 100644 --- a/winpty/Cargo.toml +++ b/winpty/Cargo.toml @@ -18,5 +18,5 @@ winapi = { version = "0.3", features = ["winnt", "processthreadsapi"] } [target.'cfg(windows)'.build-dependencies] embed-resource = "1.1.4" tempfile = "3.0.4" -reqwest = "0.9" +http_req = "0.5" zip = "0.5" diff --git a/winpty/build.rs b/winpty/build.rs index 2f4c4565..925ebf99 100644 --- a/winpty/build.rs +++ b/winpty/build.rs @@ -13,7 +13,7 @@ use std::path::Path; #[cfg(windows)] use embed_resource; #[cfg(windows)] -use reqwest; +use http_req; #[cfg(windows)] use tempfile; #[cfg(windows)] @@ -43,15 +43,26 @@ fn main() { fn aquire_winpty_agent(out_path: &Path) { let tmp_dir = tempfile::Builder::new().prefix("alacritty_build").tempdir().unwrap(); - let mut response = reqwest::get(WINPTY_PACKAGE_URL).unwrap(); let mut file = OpenOptions::new() .read(true) .write(true) .create(true) .open(tmp_dir.path().join("winpty_package.zip")) .unwrap(); - - io::copy(&mut response, &mut file).unwrap(); + let mut redirects = 0; + let mut url = WINPTY_PACKAGE_URL.to_string(); + loop { + let res = http_req::request::get(url.clone(), &mut file).unwrap(); + if res.status_code().is_redirect() { + redirects += 1; + url = res.headers().get("Location").unwrap().to_string(); + if redirects > 5 { + panic!("Too many redirects"); + } + } else { + break; + } + } let mut archive = zip::ZipArchive::new(file).unwrap(); |