@@ -21,6 +21,31 @@ fn try_run(config: &Config, cmd: &mut Command) -> Result<(), ()> {
21
21
config. try_run ( cmd)
22
22
}
23
23
24
+ fn extract_curl_version ( out : & [ u8 ] ) -> f32 {
25
+ let out = & out[ 5 ..] ;
26
+ let Some ( i) = out. iter ( ) . position ( |& x| x == b' ' ) else { return 0.0 } ;
27
+ let out = & out[ ..i] ;
28
+ let Some ( k) = out. iter ( ) . rev ( ) . position ( |& x| x == b'.' ) else { return 0.0 } ;
29
+ let out = & out[ ..out. len ( ) -k-1 ] ;
30
+ std:: str:: from_utf8 ( out) . unwrap ( ) . parse ( ) . unwrap_or ( 0.0 )
31
+ }
32
+
33
+ #[ test]
34
+ fn test_extract_curl_version ( ) {
35
+ assert_eq ! ( extract_curl_version( b"\
36
+ curl 8.4.0 (x86_64-pc-linux-gnu) libcurl/8.4.0 \
37
+ OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.4 \
38
+ libssh2/1.11.0 nghttp2/1.57.0") , 8.4 ) ;
39
+ }
40
+
41
+ fn curl_version ( ) -> f32 {
42
+ let mut curl = Command :: new ( "curl" ) ;
43
+ curl. arg ( "-V" ) ;
44
+ let Ok ( out) = curl. output ( ) else { return 0.0 } ;
45
+ let out = out. stdout ;
46
+ extract_curl_version ( & out)
47
+ }
48
+
24
49
/// Generic helpers that are useful anywhere in bootstrap.
25
50
impl Config {
26
51
pub fn is_verbose ( & self ) -> bool {
@@ -219,6 +244,8 @@ impl Config {
219
244
"30" , // timeout if cannot connect within 30 seconds
220
245
"-o" ,
221
246
tempfile. to_str ( ) . unwrap ( ) ,
247
+ "--continue-at" ,
248
+ "-" ,
222
249
"--retry" ,
223
250
"3" ,
224
251
"-SRf" ,
@@ -229,6 +256,10 @@ impl Config {
229
256
} else {
230
257
curl. arg ( "--progress-bar" ) ;
231
258
}
259
+ // --retry-all-errors was added in 7.71.0, don't use it if curl is old.
260
+ if dbg ! ( curl_version( ) ) > 7.70 {
261
+ curl. arg ( "--retry-all-errors" ) ;
262
+ }
232
263
curl. arg ( url) ;
233
264
if !self . check_run ( & mut curl) {
234
265
if self . build . contains ( "windows-msvc" ) {
0 commit comments