From 75289cc2b486af2da23efd507c9daf916bde2aa5 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 3 Mar 2023 13:29:58 +1100 Subject: [PATCH] Only use `GET` in `remote::Client::remote_gettable` (#847) Fixed #835 Using `HEAD` for this would often cause false negative that requires the `Client` to fallback to `GET`, which creates a lot of requests even if the url doesn't exist and then get cargo-binstall rate limited by GitHub/GitLab/etc. Signed-off-by: Jiahao XU --- crates/binstalk-downloader/src/remote.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/binstalk-downloader/src/remote.rs b/crates/binstalk-downloader/src/remote.rs index 8a1f24f1..09564d9a 100644 --- a/crates/binstalk-downloader/src/remote.rs +++ b/crates/binstalk-downloader/src/remote.rs @@ -279,11 +279,9 @@ impl Client { } } - /// Check if remote exists using `Method::HEAD` or `Method::GET` as fallback. + /// Check if remote exists using `Method::GET`. pub async fn remote_gettable(&self, url: Url) -> Result { - self.head_or_fallback_to_get(url, false) - .await - .map(|response| response.status().is_success()) + Ok(self.get(url).send(false).await?.status().is_success()) } /// Attempt to get final redirected url using `Method::HEAD` or fallback