@@ -416,6 +416,23 @@ impl<'cfg> PackageSet<'cfg> {
416
416
}
417
417
}
418
418
419
+ // When dynamically linked against libcurl, we want to ignore some failures
420
+ // when using old versions that don't support certain features.
421
+ macro_rules! try_old_curl {
422
+ ( $e: expr, $msg: expr) => {
423
+ let result = $e;
424
+ if cfg!( target_os = "macos" ) {
425
+ if let Err ( e) = result {
426
+ warn!( "ignoring libcurl {} error: {}" , $msg, e) ;
427
+ }
428
+ } else {
429
+ result. with_context( |_| {
430
+ format_err!( "failed to enable {}, is curl not built right?" , $msg)
431
+ } ) ?;
432
+ }
433
+ } ;
434
+ }
435
+
419
436
impl < ' a , ' cfg > Downloads < ' a , ' cfg > {
420
437
/// Starts to download the package for the `id` specified.
421
438
///
@@ -480,14 +497,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
480
497
// errors here on OSX, but consider this a fatal error to not activate
481
498
// HTTP/2 on all other platforms.
482
499
if self . set . multiplexing {
483
- let result = handle. http_version ( HttpVersion :: V2 ) ;
484
- if cfg ! ( target_os = "macos" ) {
485
- if let Err ( e) = result {
486
- warn ! ( "ignoring HTTP/2 activation error: {}" , e)
487
- }
488
- } else {
489
- result. with_context ( |_| "failed to enable HTTP2, is curl not built right?" ) ?;
490
- }
500
+ try_old_curl ! ( handle. http_version( HttpVersion :: V2 ) , "HTTP2" ) ;
491
501
} else {
492
502
handle. http_version ( HttpVersion :: V11 ) ?;
493
503
}
@@ -499,7 +509,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
499
509
// Once the main one is opened we realized that pipelining is possible
500
510
// and multiplexing is possible with static.crates.io. All in all this
501
511
// reduces the number of connections done to a more manageable state.
502
- handle. pipewait ( true ) ? ;
512
+ try_old_curl ! ( handle. pipewait( true ) , "pipewait" ) ;
503
513
504
514
handle. write_function ( move |buf| {
505
515
debug ! ( "{} - {} bytes of data" , token, buf. len( ) ) ;
0 commit comments