diff --git a/src/cli/settings/ls.rs b/src/cli/settings/ls.rs index 1d471c498..2a7dc14c6 100644 --- a/src/cli/settings/ls.rs +++ b/src/cli/settings/ls.rs @@ -75,6 +75,7 @@ mod tests { go_set_gopath = false go_set_goroot = true go_skip_checksum = false + http_timeout = 30 jobs = 2 legacy_version_file = true legacy_version_file_disable_tools = [] @@ -117,6 +118,7 @@ mod tests { go_set_gopath go_set_goroot go_skip_checksum + http_timeout jobs legacy_version_file legacy_version_file_disable_tools diff --git a/src/cli/settings/set.rs b/src/cli/settings/set.rs index 79ebae77d..e586247fe 100644 --- a/src/cli/settings/set.rs +++ b/src/cli/settings/set.rs @@ -36,6 +36,7 @@ impl SettingsSet { "go_set_gopath" => parse_bool(&self.value)?, "go_set_goroot" => parse_bool(&self.value)?, "go_skip_checksum" => parse_bool(&self.value)?, + "http_timeout" => parse_i64(&self.value)?, "jobs" => parse_i64(&self.value)?, "legacy_version_file" => parse_bool(&self.value)?, "node_compile" => parse_bool(&self.value)?, @@ -139,6 +140,7 @@ pub mod tests { go_set_gopath = false go_set_goroot = true go_skip_checksum = false + http_timeout = 30 jobs = 2 legacy_version_file = false legacy_version_file_disable_tools = [] diff --git a/src/cli/settings/unset.rs b/src/cli/settings/unset.rs index 9de68e9ff..a874dc9d0 100644 --- a/src/cli/settings/unset.rs +++ b/src/cli/settings/unset.rs @@ -57,6 +57,7 @@ mod tests { go_set_gopath = false go_set_goroot = true go_skip_checksum = false + http_timeout = 30 jobs = 2 legacy_version_file = true legacy_version_file_disable_tools = [] diff --git a/src/config/settings.rs b/src/config/settings.rs index 2c134e19c..46f8fc437 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -74,6 +74,8 @@ pub struct Settings { /// set to true to skip checksum verification when downloading go sdk tarballs #[config(env = "MISE_GO_SKIP_CHECKSUM", default = false)] pub go_skip_checksum: bool, + #[config(env = "MISE_HTTP_TIMEOUT", default = 30)] + pub http_timeout: u64, #[config(env = "MISE_JOBS", default = 4)] pub jobs: usize, #[config(env = "MISE_LEGACY_VERSION_FILE", default = true)] diff --git a/src/http.rs b/src/http.rs index 28b80bd67..3ee524c01 100644 --- a/src/http.rs +++ b/src/http.rs @@ -10,6 +10,7 @@ use tokio::runtime::Runtime; use url::Url; use crate::cli::version; +use crate::config::Settings; use crate::env::MISE_FETCH_REMOTE_VERSIONS_TIMEOUT; use crate::file::display_path; use crate::ui::progress_report::SingleReport; @@ -19,7 +20,8 @@ use crate::{env, file}; pub static HTTP_VERSION_CHECK: Lazy = Lazy::new(|| Client::new(Duration::from_secs(3)).unwrap()); -pub static HTTP: Lazy = Lazy::new(|| Client::new(Duration::from_secs(30)).unwrap()); +pub static HTTP: Lazy = + Lazy::new(|| Client::new(Duration::from_secs(Settings::get().http_timeout)).unwrap()); pub static HTTP_FETCH: Lazy = Lazy::new(|| Client::new(*MISE_FETCH_REMOTE_VERSIONS_TIMEOUT).unwrap());