1
1
//! Access to a HTTP-based crate registry. See [`HttpRegistry`] for details.
2
2
3
3
use crate :: core:: { PackageId , SourceId } ;
4
- use crate :: ops:: { self } ;
4
+ use crate :: ops;
5
5
use crate :: sources:: registry:: download;
6
6
use crate :: sources:: registry:: MaybeLock ;
7
7
use crate :: sources:: registry:: { LoadResponse , RegistryConfig , RegistryData } ;
@@ -11,9 +11,9 @@ use crate::util::network::sleep::SleepTracker;
11
11
use crate :: util:: { auth, Config , Filesystem , IntoUrl , Progress , ProgressStyle } ;
12
12
use anyhow:: Context ;
13
13
use cargo_util:: paths;
14
- use curl:: easy:: { Easy , HttpVersion , List } ;
14
+ use curl:: easy:: { Easy , List } ;
15
15
use curl:: multi:: { EasyHandle , Multi } ;
16
- use log:: { debug, trace, warn } ;
16
+ use log:: { debug, trace} ;
17
17
use std:: cell:: RefCell ;
18
18
use std:: collections:: { HashMap , HashSet } ;
19
19
use std:: fs:: { self , File } ;
@@ -383,7 +383,7 @@ impl<'cfg> HttpRegistry<'cfg> {
383
383
}
384
384
let config_json_path = self
385
385
. assert_index_locked ( & self . index_path )
386
- . join ( "config.json" ) ;
386
+ . join ( RegistryConfig :: NAME ) ;
387
387
match fs:: read ( & config_json_path) {
388
388
Ok ( raw_data) => match serde_json:: from_slice ( & raw_data) {
389
389
Ok ( json) => {
@@ -404,12 +404,12 @@ impl<'cfg> HttpRegistry<'cfg> {
404
404
fn config ( & mut self ) -> Poll < CargoResult < & RegistryConfig > > {
405
405
debug ! ( "loading config" ) ;
406
406
let index_path = self . assert_index_locked ( & self . index_path ) ;
407
- let config_json_path = index_path. join ( "config.json" ) ;
408
- if self . is_fresh ( Path :: new ( "config.json" ) ) && self . config_cached ( ) ?. is_some ( ) {
407
+ let config_json_path = index_path. join ( RegistryConfig :: NAME ) ;
408
+ if self . is_fresh ( Path :: new ( RegistryConfig :: NAME ) ) && self . config_cached ( ) ?. is_some ( ) {
409
409
return Poll :: Ready ( Ok ( self . registry_config . as_ref ( ) . unwrap ( ) ) ) ;
410
410
}
411
411
412
- match ready ! ( self . load( Path :: new( "" ) , Path :: new( "config.json" ) , None ) ?) {
412
+ match ready ! ( self . load( Path :: new( "" ) , Path :: new( RegistryConfig :: NAME ) , None ) ?) {
413
413
LoadResponse :: Data {
414
414
raw_data,
415
415
index_version : _,
@@ -543,7 +543,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
543
543
}
544
544
StatusCode :: Unauthorized
545
545
if !self . auth_required
546
- && path == Path :: new ( "config.json" )
546
+ && path == Path :: new ( RegistryConfig :: NAME )
547
547
&& self . config . cli_unstable ( ) . registry_auth =>
548
548
{
549
549
debug ! ( "re-attempting request for config.json with authorization included." ) ;
@@ -593,7 +593,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
593
593
}
594
594
}
595
595
596
- if path != Path :: new ( "config.json" ) {
596
+ if path != Path :: new ( RegistryConfig :: NAME ) {
597
597
self . auth_required = ready ! ( self . config( ) ?) . auth_required ;
598
598
} else if !self . auth_required {
599
599
// Check if there's a cached config that says auth is required.
@@ -618,20 +618,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
618
618
handle. follow_location ( true ) ?;
619
619
620
620
// Enable HTTP/2 if possible.
621
- if self . multiplexing {
622
- crate :: try_old_curl!( handle. http_version( HttpVersion :: V2 ) , "HTTP2" ) ;
623
- } else {
624
- handle. http_version ( HttpVersion :: V11 ) ?;
625
- }
626
-
627
- // This is an option to `libcurl` which indicates that if there's a
628
- // bunch of parallel requests to the same host they all wait until the
629
- // pipelining status of the host is known. This means that we won't
630
- // initiate dozens of connections to crates.io, but rather only one.
631
- // Once the main one is opened we realized that pipelining is possible
632
- // and multiplexing is possible with static.crates.io. All in all this
633
- // reduces the number of connections done to a more manageable state.
634
- crate :: try_old_curl!( handle. pipewait( true ) , "pipewait" ) ;
621
+ crate :: try_old_curl_http2_pipewait!( self . multiplexing, handle) ;
635
622
636
623
let mut headers = List :: new ( ) ;
637
624
// Include a header to identify the protocol. This allows the server to
0 commit comments