diff options
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(); |