Reuse reqwest client in crates_io_api::AsyncClient (#349)

This commit is contained in:
Jiahao XU 2022-09-06 14:52:05 +10:00 committed by GitHub
parent e7d2eb1aef
commit f7ad78288b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 132 additions and 125 deletions

View file

@ -20,7 +20,7 @@ pkg-fmt = "zip"
[dependencies]
binstall = { path = "../lib", version = "0.0.0" }
clap = { version = "3.2.17", features = ["derive"] }
crates_io_api = { version = "0.8.0", default-features = false }
crates_io_api = { version = "0.8.1", default-features = false }
dirs = "4.0.0"
log = "0.4.17"
miette = "5.3.0"

View file

@ -35,11 +35,8 @@ pub async fn install_crates(mut args: Args, jobserver_client: LazyJobserverClien
let client = create_reqwest_client(args.min_tls_version.map(|v| v.into()))?;
// Build crates.io api client
let crates_io_api_client = crates_io_api::AsyncClient::new(
"cargo-binstall (https://github.com/ryankurte/cargo-binstall)",
Duration::from_millis(100),
)
.expect("bug: invalid user agent");
let crates_io_api_client =
crates_io_api::AsyncClient::with_http_client(client.clone(), Duration::from_millis(100));
// Initialize UI thread
let mut uithread = UIThread::new(!args.no_confirm);