mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 12:10:02 +00:00
Disable tcp_nodelay
for reqwest::Client
and add rate limiting for https requests (#458)
This commit is contained in:
parent
8398ec2d4b
commit
76bc030f90
12 changed files with 243 additions and 99 deletions
|
@ -2,14 +2,15 @@ use std::{path::Path, sync::Arc};
|
|||
|
||||
use compact_str::CompactString;
|
||||
use log::debug;
|
||||
use reqwest::Client;
|
||||
use reqwest::Method;
|
||||
use tokio::task::JoinHandle;
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
errors::BinstallError,
|
||||
helpers::{download::Download, remote::remote_exists},
|
||||
helpers::{
|
||||
download::Download,
|
||||
remote::{Client, Method},
|
||||
},
|
||||
manifests::cargo_toml_binstall::{PkgFmt, PkgMeta},
|
||||
};
|
||||
|
||||
|
@ -43,7 +44,9 @@ impl super::Fetcher for QuickInstall {
|
|||
let url = self.package_url();
|
||||
self.report();
|
||||
debug!("Checking for package at: '{url}'");
|
||||
remote_exists(self.client.clone(), Url::parse(&url)?, Method::HEAD).await
|
||||
self.client
|
||||
.remote_exists(Url::parse(&url)?, Method::HEAD)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
||||
|
@ -112,15 +115,7 @@ impl QuickInstall {
|
|||
let url = Url::parse(&stats_url)?;
|
||||
debug!("Sending installation report to quickinstall ({url})");
|
||||
|
||||
client
|
||||
.request(Method::HEAD, url.clone())
|
||||
.send()
|
||||
.await
|
||||
.map_err(|err| BinstallError::Http {
|
||||
method: Method::HEAD,
|
||||
url,
|
||||
err,
|
||||
})?;
|
||||
client.remote_exists(url, Method::HEAD).await?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue