@@ -367,8 +367,12 @@ 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- handle. low_speed_limit ( 10 /* bytes per second */ ) ?;
371- handle. low_speed_time ( 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+ }
372376 if let Some ( proxy) = http_proxy ( config) ? {
373377 handle. proxy ( & proxy) ?;
374378 }
@@ -390,6 +394,22 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
390394 Ok ( ( ) )
391395}
392396
397+ /// 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 > > {
399+ 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 ) ) ) ;
409+ }
410+ Ok ( Some ( Duration :: new ( 30 , 0 ) ) )
411+ }
412+
393413/// Find an explicit HTTP proxy if one is available.
394414///
395415/// Favor cargo's `http.proxy`, then git's `http.proxy`. Proxies specified
0 commit comments