@@ -14,7 +14,7 @@ use uv_small_str::SmallString;
14
14
15
15
use crate :: cached_client:: { CacheControl , CachedClientError } ;
16
16
use crate :: html:: SimpleHtml ;
17
- use crate :: { Connectivity , Error , ErrorKind , OwnedArchive , RegistryClient } ;
17
+ use crate :: { CachedClient , Connectivity , Error , ErrorKind , OwnedArchive } ;
18
18
19
19
#[ derive( Debug , thiserror:: Error ) ]
20
20
pub enum FlatIndexError {
@@ -91,14 +91,19 @@ impl FlatIndexEntries {
91
91
/// remote HTML indexes).
92
92
#[ derive( Debug , Clone ) ]
93
93
pub struct FlatIndexClient < ' a > {
94
- client : & ' a RegistryClient ,
94
+ client : & ' a CachedClient ,
95
+ connectivity : Connectivity ,
95
96
cache : & ' a Cache ,
96
97
}
97
98
98
99
impl < ' a > FlatIndexClient < ' a > {
99
100
/// Create a new [`FlatIndexClient`].
100
- pub fn new ( client : & ' a RegistryClient , cache : & ' a Cache ) -> Self {
101
- Self { client, cache }
101
+ pub fn new ( client : & ' a CachedClient , connectivity : Connectivity , cache : & ' a Cache ) -> Self {
102
+ Self {
103
+ client,
104
+ connectivity,
105
+ cache,
106
+ }
102
107
}
103
108
104
109
/// Read the directories and flat remote indexes from `--find-links`.
@@ -157,7 +162,7 @@ impl<'a> FlatIndexClient<'a> {
157
162
"html" ,
158
163
format ! ( "{}.msgpack" , cache_digest( & url. to_string( ) ) ) ,
159
164
) ;
160
- let cache_control = match self . client . connectivity ( ) {
165
+ let cache_control = match self . connectivity {
161
166
Connectivity :: Online => CacheControl :: from (
162
167
self . cache
163
168
. freshness ( & cache_entry, None , None )
@@ -168,7 +173,8 @@ impl<'a> FlatIndexClient<'a> {
168
173
169
174
let flat_index_request = self
170
175
. client
171
- . uncached_client ( url)
176
+ . uncached ( )
177
+ . for_host ( url)
172
178
. get ( url. clone ( ) )
173
179
. header ( "Accept-Encoding" , "gzip" )
174
180
. header ( "Accept" , "text/html" )
@@ -210,7 +216,6 @@ impl<'a> FlatIndexClient<'a> {
210
216
} ;
211
217
let response = self
212
218
. client
213
- . cached_client ( )
214
219
. get_cacheable_with_retry (
215
220
flat_index_request,
216
221
& cache_entry,
0 commit comments