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 <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-03 13:29:58 +11:00 committed by GitHub
parent 8eee318ccd
commit 75289cc2b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<bool, Error> {
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