From 718e30ee865fe0b0c75f50b940aa5914825582a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 1 Oct 2019 19:10:35 +0300 Subject: [PATCH] download: Remove cURL backend --- Cargo.lock | 56 ------ Cargo.toml | 6 +- README.md | 19 -- ci/build-run-docker.bash | 2 +- download/Cargo.toml | 14 +- download/src/errors.rs | 6 +- download/src/lib.rs | 186 +----------------- download/tests/download-curl-resume.rs | 76 ------- ...d-reqwest-resume.rs => download-resume.rs} | 8 +- src/utils/notifications.rs | 8 +- src/utils/utils.rs | 15 +- 11 files changed, 19 insertions(+), 377 deletions(-) delete mode 100644 download/tests/download-curl-resume.rs rename download/tests/{download-reqwest-resume.rs => download-resume.rs} (90%) diff --git a/Cargo.lock b/Cargo.lock index 254324ed0d..092e2cefbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,35 +254,6 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "curl" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "curl-sys 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.49 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "curl-sys" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.49 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "digest" version = "0.8.1" @@ -295,7 +266,6 @@ dependencies = [ name = "download" version = "0.6.3" dependencies = [ - "curl 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", "env_proxy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -618,17 +588,6 @@ name = "libc" version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "libz-sys" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lock_api" version = "0.1.5" @@ -1343,17 +1302,6 @@ name = "smallvec" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "socket2" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "socks" version = "0.3.2" @@ -1841,8 +1789,6 @@ dependencies = [ "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -"checksum curl 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ed9a22aa8c4e49ac0c896279ef532a43a7df2f54fcd19fa36960de029f965f" -"checksum curl-sys 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5e90ae10f635645cba9cad1023535f54915a95c58c44751c6ed70dbaeb17a408" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" @@ -1880,7 +1826,6 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" -"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lzma-sys 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "53e48818fd597d46155132bbbb9505d6d1b3d360b4ee25cfa91c406f8a90fe91" @@ -1957,7 +1902,6 @@ dependencies = [ "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" -"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum socks 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e6a64cfa9346d26e836a49fcc1ddfcb4d3df666b6787b6864db61d4918e1cbc2" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" diff --git a/Cargo.toml b/Cargo.toml index 28de0660c5..0ab9acb9bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,6 @@ repository = "https://github.com/rust-lang/rustup.rs" description = "Manage multiple rust installations with ease" [features] -default = ["curl-backend", "reqwest-backend"] -curl-backend = ["download/curl-backend"] -reqwest-backend = ["download/reqwest-backend"] vendored-openssl = ['openssl/vendored'] # Include in the default set to disable self-update and uninstall. no-self-update = [] @@ -32,8 +29,7 @@ home = "0.5" lazy_static = "1" libc = "0.2" opener = "0.4.0" -# Used by `curl` or `reqwest` backend although it isn't imported -# by our rustup. +# Used by `reqwest` although it isn't imported by our rustup. openssl = { version = "0.10", optional = true } pulldown-cmark = { version = "0.6", default-features = false } rand = "0.7" diff --git a/README.md b/README.md index 478b9eab82..c113467ac5 100644 --- a/README.md +++ b/README.md @@ -559,25 +559,6 @@ On Windows, the command would be: set https_proxy=socks5://proxy.example.com:1080 ``` -If you need a more complex setup, rustup supports the convention used by -the __curl__ program, documented in the ENVIRONMENT section of -[its manual page][curlman]. - -The use of `curl` is presently **deprecated**, however it can still be used by -providing the `RUSTUP_USE_CURL` environment variable, for example: - -```bash -RUSTUP_USE_CURL=1 rustup update -``` - -Note that some versions of `libcurl` apparently require you to drop the -`http://` or `https://` prefix in environment variables. For example, -`export http_proxy=proxy.example.com:1080` (and likewise for HTTPS). -If you are getting an SSL `unknown protocol` error from `rustup` via `libcurl` -but the command-line `curl` command works fine, this may be the problem. - -[curlman]: https://curl.haxx.se/docs/manpage.html - ## Examples diff --git a/ci/build-run-docker.bash b/ci/build-run-docker.bash index 905987c1ab..560935d426 100644 --- a/ci/build-run-docker.bash +++ b/ci/build-run-docker.bash @@ -56,7 +56,7 @@ docker run \ # check that rustup-init was built with ssl support # see https://github.com/rust-lang/rustup.rs/issues/1051 -if ! (nm target/"${TARGET}"/release/rustup-init | grep -q Curl_ssl_version); then +if ! (nm target/"${TARGET}"/release/rustup-init | grep -q openssl_sys); then echo "Missing ssl support!!!!" >&2 exit 1 fi diff --git a/download/Cargo.toml b/download/Cargo.toml index 093ae59211..bc57f15a34 100644 --- a/download/Cargo.toml +++ b/download/Cargo.toml @@ -7,20 +7,12 @@ authors = [ "Brian Anderson " ] license = "MIT/Apache-2.0" -[features] - -default = ["reqwest-backend"] - -curl-backend = ["curl"] -reqwest-backend = ["reqwest", "env_proxy", "lazy_static"] - [dependencies] +lazy_static = "1.0" +env_proxy = "0.3.1" error-chain = "0.12" +reqwest = { version = "0.9.14", features = ["socks"] } url = "1.7" -curl = { version = "0.4.11", optional = true } -env_proxy = { version = "0.3.1", optional = true } -lazy_static = { version = "1.0", optional = true } -reqwest = { version = "0.9.14", features = ["socks"], optional = true } [dev-dependencies] futures = "0.1" diff --git a/download/src/errors.rs b/download/src/errors.rs index bb263a4e77..cabfe4b835 100644 --- a/download/src/errors.rs +++ b/download/src/errors.rs @@ -5,7 +5,7 @@ error_chain! { foreign_links { Io(std::io::Error); - Reqwest(::reqwest::Error) #[cfg(feature = "reqwest-backend")]; + Reqwest(::reqwest::Error); } errors { @@ -16,9 +16,5 @@ error_chain! { FileNotFound { description("file not found") } - BackendUnavailable(be: &'static str) { - description("download backend unavailable") - display("download backend '{}' unavailable", be) - } } } diff --git a/download/src/lib.rs b/download/src/lib.rs index 35c68ed6b3..3484b1dfb8 100644 --- a/download/src/lib.rs +++ b/download/src/lib.rs @@ -7,12 +7,6 @@ use url::Url; mod errors; pub use crate::errors::*; -#[derive(Debug, Copy, Clone)] -pub enum Backend { - Curl, - Reqwest, -} - #[derive(Debug, Copy, Clone)] pub enum Event<'a> { ResumingPartialDownload, @@ -22,20 +16,11 @@ pub enum Event<'a> { DownloadDataReceived(&'a [u8]), } -fn download_with_backend( - backend: Backend, - url: &Url, - resume_from: u64, - callback: &dyn Fn(Event<'_>) -> Result<()>, -) -> Result<()> { - match backend { - Backend::Curl => curl::download(url, resume_from, callback), - Backend::Reqwest => reqwest_be::download(url, resume_from, callback), - } +fn download(url: &Url, resume_from: u64, callback: &dyn Fn(Event<'_>) -> Result<()>) -> Result<()> { + reqwest_be::download(url, resume_from, callback) } -pub fn download_to_path_with_backend( - backend: Backend, +pub fn download_to_path( url: &Url, path: &Path, resume_from_partial: bool, @@ -95,7 +80,7 @@ pub fn download_to_path_with_backend( let file = RefCell::new(file); - download_with_backend(backend, url, resume_from, &|event| { + download(url, resume_from, &|event| { if let Event::DownloadDataReceived(data) = event { file.borrow_mut() .write_all(data) @@ -119,130 +104,6 @@ pub fn download_to_path_with_backend( }) } -/// Download via libcurl; encrypt with the native (or OpenSSl) TLS -/// stack via libcurl -#[cfg(feature = "curl-backend")] -pub mod curl { - use super::Event; - use crate::errors::*; - use curl::easy::Easy; - use std::cell::RefCell; - use std::str; - use std::time::Duration; - use url::Url; - - pub fn download( - url: &Url, - resume_from: u64, - callback: &dyn Fn(Event<'_>) -> Result<()>, - ) -> Result<()> { - // Fetch either a cached libcurl handle (which will preserve open - // connections) or create a new one if it isn't listed. - // - // Once we've acquired it, reset the lifetime from 'static to our local - // scope. - thread_local!(static EASY: RefCell = RefCell::new(Easy::new())); - EASY.with(|handle| { - let mut handle = handle.borrow_mut(); - - handle - .url(&url.to_string()) - .chain_err(|| "failed to set url")?; - handle - .follow_location(true) - .chain_err(|| "failed to set follow redirects")?; - - if resume_from > 0 { - handle - .resume_from(resume_from) - .chain_err(|| "setting the range header for download resumption")?; - } else { - // an error here indicates that the range header isn't supported by underlying curl, - // so there's nothing to "clear" - safe to ignore this error. - let _ = handle.resume_from(0); - } - - // Take at most 30s to connect - handle - .connect_timeout(Duration::new(30, 0)) - .chain_err(|| "failed to set connect timeout")?; - - { - let cberr = RefCell::new(None); - let mut transfer = handle.transfer(); - - // Data callback for libcurl which is called with data that's - // downloaded. We just feed it into our hasher and also write it out - // to disk. - transfer - .write_function(|data| match callback(Event::DownloadDataReceived(data)) { - Ok(()) => Ok(data.len()), - Err(e) => { - *cberr.borrow_mut() = Some(e); - Ok(0) - } - }) - .chain_err(|| "failed to set write")?; - - // Listen for headers and parse out a `Content-Length` (case-insensitive) if it - // comes so we know how much we're downloading. - transfer - .header_function(|header| { - if let Ok(data) = str::from_utf8(header) { - let prefix = "content-length: "; - if data.to_ascii_lowercase().starts_with(prefix) { - if let Ok(s) = data[prefix.len()..].trim().parse::() { - let msg = Event::DownloadContentLengthReceived(s + resume_from); - match callback(msg) { - Ok(()) => (), - Err(e) => { - *cberr.borrow_mut() = Some(e); - return false; - } - } - } - } - } - true - }) - .chain_err(|| "failed to set header")?; - - // If an error happens check to see if we had a filesystem error up - // in `cberr`, but we always want to punt it up. - transfer.perform().or_else(|e| { - // If the original error was generated by one of our - // callbacks, return it. - match cberr.borrow_mut().take() { - Some(cberr) => Err(cberr), - None => { - // Otherwise, return the error from curl - if e.is_file_couldnt_read_file() { - Err(e).chain_err(|| ErrorKind::FileNotFound) - } else { - Err(e).chain_err(|| "error during download") - } - } - } - })?; - } - - // If we didn't get a 20x or 0 ("OK" for files) then return an error - let code = handle - .response_code() - .chain_err(|| "failed to get response code")?; - match code { - 0 | 200..=299 => {} - _ => { - return Err(ErrorKind::HttpStatus(code).into()); - } - }; - - Ok(()) - }) - } -} - -#[cfg(feature = "reqwest-backend")] pub mod reqwest_be { use super::Event; use crate::errors::*; @@ -301,11 +162,10 @@ pub mod reqwest_be { }; // woah, an unwrap?! - // It's OK. This is the same as what is happening in curl. + // It's OK. // - // The curl::Easy::new() internally assert!s that the initialized - // Easy is not null. Inside reqwest, the errors here would be from - // the TLS library returning a null pointer as well. + // Inside reqwest, the errors here would be from the TLS library + // returning a null pointer. catcher().unwrap() }; } @@ -363,35 +223,3 @@ pub mod reqwest_be { } } } - -#[cfg(not(feature = "curl-backend"))] -pub mod curl { - - use super::Event; - use crate::errors::*; - use url::Url; - - pub fn download( - _url: &Url, - _resume_from: u64, - _callback: &dyn Fn(Event<'_>) -> Result<()>, - ) -> Result<()> { - Err(ErrorKind::BackendUnavailable("curl").into()) - } -} - -#[cfg(not(feature = "reqwest-backend"))] -pub mod reqwest_be { - - use super::Event; - use crate::errors::*; - use url::Url; - - pub fn download( - _url: &Url, - _resume_from: u64, - _callback: &dyn Fn(Event<'_>) -> Result<()>, - ) -> Result<()> { - Err(ErrorKind::BackendUnavailable("reqwest").into()) - } -} diff --git a/download/tests/download-curl-resume.rs b/download/tests/download-curl-resume.rs deleted file mode 100644 index 91246f9136..0000000000 --- a/download/tests/download-curl-resume.rs +++ /dev/null @@ -1,76 +0,0 @@ -#![cfg(feature = "curl-backend")] - -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Mutex; - -use url::Url; - -use download::*; - -mod support; -use crate::support::{serve_file, tmp_dir, write_file}; - -#[test] -fn partially_downloaded_file_gets_resumed_from_byte_offset() { - let tmpdir = tmp_dir(); - let from_path = tmpdir.path().join("download-source"); - write_file(&from_path, "xxx45"); - - let target_path = tmpdir.path().join("downloaded"); - write_file(&target_path, "123"); - - let from_url = Url::from_file_path(&from_path).unwrap(); - download_to_path_with_backend(Backend::Curl, &from_url, &target_path, true, None) - .expect("Test download failed"); - - assert_eq!(std::fs::read_to_string(&target_path).unwrap(), "12345"); -} - -#[test] -fn callback_gets_all_data_as_if_the_download_happened_all_at_once() { - let tmpdir = tmp_dir(); - let target_path = tmpdir.path().join("downloaded"); - write_file(&target_path, "123"); - - let addr = serve_file(b"xxx45".to_vec()); - - let from_url = format!("http://{}", addr).parse().unwrap(); - - let callback_partial = AtomicBool::new(false); - let callback_len = Mutex::new(None); - let received_in_callback = Mutex::new(Vec::new()); - - download_to_path_with_backend( - Backend::Curl, - &from_url, - &target_path, - true, - Some(&|msg| { - match msg { - Event::ResumingPartialDownload => { - assert!(!callback_partial.load(Ordering::SeqCst)); - callback_partial.store(true, Ordering::SeqCst); - } - Event::DownloadContentLengthReceived(len) => { - let mut flag = callback_len.lock().unwrap(); - assert!(flag.is_none()); - *flag = Some(len); - } - Event::DownloadDataReceived(data) => { - for b in data.iter() { - received_in_callback.lock().unwrap().push(b.clone()); - } - } - } - - Ok(()) - }), - ) - .expect("Test download failed"); - - assert!(callback_partial.into_inner()); - assert_eq!(*callback_len.lock().unwrap(), Some(5)); - let observed_bytes = received_in_callback.into_inner().unwrap(); - assert_eq!(observed_bytes, vec![b'1', b'2', b'3', b'4', b'5']); - assert_eq!(std::fs::read_to_string(&target_path).unwrap(), "12345"); -} diff --git a/download/tests/download-reqwest-resume.rs b/download/tests/download-resume.rs similarity index 90% rename from download/tests/download-reqwest-resume.rs rename to download/tests/download-resume.rs index c1bc212773..06920197cd 100644 --- a/download/tests/download-reqwest-resume.rs +++ b/download/tests/download-resume.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "reqwest-backend")] - use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Mutex; @@ -20,8 +18,7 @@ fn resume_partial_from_file_url() { write_file(&target_path, "123"); let from_url = Url::from_file_path(&from_path).unwrap(); - download_to_path_with_backend(Backend::Reqwest, &from_url, &target_path, true, None) - .expect("Test download failed"); + download_to_path(&from_url, &target_path, true, None).expect("Test download failed"); assert_eq!(std::fs::read_to_string(&target_path).unwrap(), "12345"); } @@ -40,8 +37,7 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() { let callback_len = Mutex::new(None); let received_in_callback = Mutex::new(Vec::new()); - download_to_path_with_backend( - Backend::Reqwest, + download_to_path( &from_url, &target_path, true, diff --git a/src/utils/notifications.rs b/src/utils/notifications.rs index 2881516182..744d115d35 100644 --- a/src/utils/notifications.rs +++ b/src/utils/notifications.rs @@ -26,8 +26,6 @@ pub enum Notification<'a> { DownloadPopUnits, NoCanonicalPath(&'a Path), ResumingPartialDownload, - UsingCurl, - UsingReqwest, /// Renaming encountered a file in use error and is retrying. /// The InUse aspect is a heuristic - the OS specifies /// Permission denied, but as we work in users home dirs and @@ -50,9 +48,7 @@ impl<'a> Notification<'a> { | DownloadPushUnits(_) | DownloadPopUnits | DownloadFinished - | ResumingPartialDownload - | UsingCurl - | UsingReqwest => NotificationLevel::Verbose, + | ResumingPartialDownload => NotificationLevel::Verbose, RenameInUse(_, _) => NotificationLevel::Info, NoCanonicalPath(_) => NotificationLevel::Warn, } @@ -85,8 +81,6 @@ impl<'a> Display for Notification<'a> { DownloadFinished => write!(f, "download finished"), NoCanonicalPath(path) => write!(f, "could not canonicalize path: '{}'", path.display()), ResumingPartialDownload => write!(f, "resuming partial download"), - UsingCurl => write!(f, "downloading with curl"), - UsingReqwest => write!(f, "downloading with reqwest"), } } } diff --git a/src/utils/utils.rs b/src/utils/utils.rs index 50a5a96f59..732e8a9883 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -186,8 +186,8 @@ fn download_file_( resume_from_partial: bool, notify_handler: &dyn Fn(Notification<'_>), ) -> Result<()> { - use download::download_to_path_with_backend; - use download::{Backend, Event}; + use download::download_to_path; + use download::Event; use sha2::Digest; use std::cell::RefCell; @@ -220,16 +220,7 @@ fn download_file_( }; // Download the file - - // Keep the hyper env var around for a bit - let use_curl_backend = env::var_os("RUSTUP_USE_CURL").is_some(); - let (backend, notification) = if use_curl_backend { - (Backend::Curl, Notification::UsingCurl) - } else { - (Backend::Reqwest, Notification::UsingReqwest) - }; - notify_handler(notification); - download_to_path_with_backend(backend, url, path, resume_from_partial, Some(callback))?; + download_to_path(url, path, resume_from_partial, Some(callback))?; notify_handler(Notification::DownloadFinished);