Skip to content

Commit d6cde29

Browse files
committed
Provide http-config option for curl low-speed-limit
Fixes #5717 low-speed-time was removed because the corresponding curl-option is already set via http.timeout. removed unnecessary Option.
1 parent 0279123 commit d6cde29

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/cargo/ops/registry.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,7 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
367367
// connect phase as well as a "low speed" timeout so if we don't receive
368368
// many bytes in a large-ish period of time then we time out.
369369
handle.connect_timeout(Duration::new(30, 0))?;
370-
if let Some(config_low_speed_limit) = low_speed_limit(config)? {
371-
handle.low_speed_limit(config_low_speed_limit)?;
372-
}
373-
if let Some(config_low_speed_time) = low_speed_time(config)? {
374-
handle.low_speed_time(config_low_speed_time)?;
375-
}
370+
handle.low_speed_limit(http_low_speed_limit(config)?)?;
376371
if let Some(proxy) = http_proxy(config)? {
377372
handle.proxy(&proxy)?;
378373
}
@@ -395,19 +390,11 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
395390
}
396391

397392
/// Find an override from config for curl low-speed-limit option, otherwise use default value
398-
fn low_speed_limit(config: &Config) -> CargoResult<Option<u32>> {
393+
fn http_low_speed_limit(config: &Config) -> CargoResult<u32> {
399394
if let Some(s) = config.get::<Option<u32>>("http.low-speed-limit")? {
400-
return Ok(Some(s));
401-
}
402-
Ok(Some(10))
403-
}
404-
405-
/// Find an override from config for curl low-speed-time option, otherwise use default value
406-
fn low_speed_time(config: &Config) -> CargoResult<Option<Duration>> {
407-
if let Some(s) = config.get::<Option<u64>>("http.low-speed-time")? {
408-
return Ok(Some(Duration::new(s, 0)));
395+
return Ok(s);
409396
}
410-
Ok(Some(Duration::new(30, 0)))
397+
Ok(10)
411398
}
412399

413400
/// Find an explicit HTTP proxy if one is available.

src/doc/src/reference/config.md

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ proxy = "host:port" # HTTP proxy to use for HTTP requests (defaults to none)
9595
timeout = 60000 # Timeout for each HTTP request, in milliseconds
9696
cainfo = "cert.pem" # Path to Certificate Authority (CA) bundle (optional)
9797
check-revoke = true # Indicates whether SSL certs are checked for revocation
98+
low-speed-limit = 0 # Lower threshold for bytes/sec (10 = default, 0 = disabled)
9899

99100
[build]
100101
jobs = 1 # number of parallel jobs, defaults to # of CPUs

0 commit comments

Comments
 (0)