From d6cde29517efc47f32f4b42db22be4ae7dadedfc Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Mon, 3 Sep 2018 17:44:07 +0200 Subject: [PATCH] Provide http-config option for curl low-speed-limit Fixes rust-lang/cargo#5717 low-speed-time was removed because the corresponding curl-option is already set via http.timeout. removed unnecessary Option. --- src/cargo/ops/registry.rs | 21 ++++----------------- src/doc/src/reference/config.md | 1 + 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 09820d91aab..0ac1335f9d1 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -367,12 +367,7 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< // connect phase as well as a "low speed" timeout so if we don't receive // many bytes in a large-ish period of time then we time out. handle.connect_timeout(Duration::new(30, 0))?; - if let Some(config_low_speed_limit) = low_speed_limit(config)? { - handle.low_speed_limit(config_low_speed_limit)?; - } - if let Some(config_low_speed_time) = low_speed_time(config)? { - handle.low_speed_time(config_low_speed_time)?; - } + handle.low_speed_limit(http_low_speed_limit(config)?)?; if let Some(proxy) = http_proxy(config)? { handle.proxy(&proxy)?; } @@ -395,19 +390,11 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< } /// Find an override from config for curl low-speed-limit option, otherwise use default value -fn low_speed_limit(config: &Config) -> CargoResult> { +fn http_low_speed_limit(config: &Config) -> CargoResult { if let Some(s) = config.get::>("http.low-speed-limit")? { - return Ok(Some(s)); - } - Ok(Some(10)) -} - -/// Find an override from config for curl low-speed-time option, otherwise use default value -fn low_speed_time(config: &Config) -> CargoResult> { - if let Some(s) = config.get::>("http.low-speed-time")? { - return Ok(Some(Duration::new(s, 0))); + return Ok(s); } - Ok(Some(Duration::new(30, 0))) + Ok(10) } /// Find an explicit HTTP proxy if one is available. diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index 1eaf4511e09..35a740faeb5 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -95,6 +95,7 @@ proxy = "host:port" # HTTP proxy to use for HTTP requests (defaults to none) timeout = 60000 # Timeout for each HTTP request, in milliseconds cainfo = "cert.pem" # Path to Certificate Authority (CA) bundle (optional) check-revoke = true # Indicates whether SSL certs are checked for revocation +low-speed-limit = 0 # Lower threshold for bytes/sec (10 = default, 0 = disabled) [build] jobs = 1 # number of parallel jobs, defaults to # of CPUs