diff --git a/src/tool_configuration.rs b/src/tool_configuration.rs index 8f85adec..392b13b1 100644 --- a/src/tool_configuration.rs +++ b/src/tool_configuration.rs @@ -6,6 +6,10 @@ use std::{path::PathBuf, sync::Arc}; use crate::console_utils::LoggingOutputHandler; use rattler_networking::{authentication_storage, AuthenticationMiddleware, AuthenticationStorage}; use reqwest_middleware::ClientWithMiddleware; + +/// The user agent to use for the reqwest client +pub const APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); + /// Global configuration for the build #[derive(Clone, Debug)] pub struct Configuration { @@ -45,9 +49,14 @@ pub fn get_auth_store(auth_file: Option) -> AuthenticationStorage { /// Create a reqwest client with the authentication middleware pub fn reqwest_client_from_auth_storage(auth_file: Option) -> ClientWithMiddleware { let auth_storage = get_auth_store(auth_file); + + let timeout = 5 * 60; reqwest_middleware::ClientBuilder::new( reqwest::Client::builder() .no_gzip() + .pool_max_idle_per_host(20) + .user_agent(APP_USER_AGENT) + .timeout(std::time::Duration::from_secs(timeout)) .build() .expect("failed to create client"), ) @@ -59,16 +68,7 @@ impl Default for Configuration { fn default() -> Self { Self { fancy_log_handler: LoggingOutputHandler::default(), - client: reqwest_middleware::ClientBuilder::new( - reqwest::Client::builder() - .no_gzip() - .build() - .expect("failed to create client"), - ) - .with_arc(Arc::new(AuthenticationMiddleware::new( - AuthenticationStorage::default(), - ))) - .build(), + client: reqwest_client_from_auth_storage(None), no_clean: false, no_test: false, use_zstd: true, diff --git a/src/upload/mod.rs b/src/upload/mod.rs index d9597e55..cdae07df 100644 --- a/src/upload/mod.rs +++ b/src/upload/mod.rs @@ -1,5 +1,6 @@ use futures::TryStreamExt; use indicatif::{style::TemplateError, HumanBytes, ProgressState}; +use rattler_build::tool_configuration::APP_USER_AGENT; use std::{ fmt::Write, path::{Path, PathBuf}, @@ -42,7 +43,7 @@ fn default_bytes_style() -> Result { fn get_default_client() -> Result { reqwest::Client::builder() .no_gzip() - .user_agent(format!("rattler-build/{}", VERSION)) + .user_agent(APP_USER_AGENT) .build() }