-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide http-config option for curl low-speed-limit/time #5957
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,8 +367,12 @@ 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))?; | ||
handle.low_speed_limit(10 /* bytes per second */)?; | ||
handle.low_speed_time(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)?; | ||
} | ||
if let Some(proxy) = http_proxy(config)? { | ||
handle.proxy(&proxy)?; | ||
} | ||
|
@@ -390,6 +394,22 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< | |
Ok(()) | ||
} | ||
|
||
/// Find an override from config for curl low-speed-limit option, otherwise use default value | ||
fn low_speed_limit(config: &Config) -> CargoResult<Option<u32>> { | ||
if let Some(s) = config.get::<Option<u32>>("http.low-speed-limit")? { | ||
return Ok(Some(s)); | ||
} | ||
Ok(Some(10)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this always returns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the Option, but instead of unwrap_or I've set the default in the function. This way, everything is in one place. |
||
} | ||
|
||
/// Find an override from config for curl low-speed-time option, otherwise use default value | ||
fn low_speed_time(config: &Config) -> CargoResult<Option<Duration>> { | ||
if let Some(s) = config.get::<Option<u64>>("http.low-speed-time")? { | ||
return Ok(Some(Duration::new(s, 0))); | ||
} | ||
Ok(Some(Duration::new(30, 0))) | ||
} | ||
|
||
/// Find an explicit HTTP proxy if one is available. | ||
/// | ||
/// Favor cargo's `http.proxy`, then git's `http.proxy`. Proxies specified | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this conflicts with
http_timeout
below, but could it suffice to avoid configuring this manually and lettinghttp_timeout
below configure it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I just didn't notice the option was configured with the http-timeout.