File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -432,18 +432,18 @@ impl AsyncClient {
432
432
let mut attempts = 0 ;
433
433
434
434
loop {
435
- match self . client . get ( url) . send ( ) . await {
436
- Ok ( resp)
437
- if attempts < self . max_retries
438
- && RETRYABLE_ERROR_CODES . contains ( & resp. status ( ) . as_u16 ( ) ) =>
439
- {
435
+ match self . client . get ( url) . send ( ) . await ? {
436
+ resp if attempts <= self . max_retries && is_status_retryable ( resp. status ( ) ) => {
440
437
task:: sleep ( delay) . await ;
441
438
attempts += 1 ;
442
439
delay *= 2 ;
443
440
}
444
- Ok ( resp) => return Ok ( resp) ,
445
- Err ( e) => return Err ( Error :: Reqwest ( e) ) ,
441
+ resp => return Ok ( resp) ,
446
442
}
447
443
}
448
444
}
449
445
}
446
+
447
+ fn is_status_retryable ( status : reqwest:: StatusCode ) -> bool {
448
+ RETRYABLE_ERROR_CODES . contains ( & status. as_u16 ( ) )
449
+ }
Original file line number Diff line number Diff line change @@ -354,16 +354,13 @@ impl BlockingClient {
354
354
let mut attempts = 0 ;
355
355
356
356
loop {
357
- match self . get_request ( url) ?. send ( ) {
358
- Ok ( resp)
359
- if attempts < self . max_retries && is_status_retryable ( resp. status_code ) =>
360
- {
357
+ match self . get_request ( url) ?. send ( ) ? {
358
+ resp if attempts <= self . max_retries && is_status_retryable ( resp. status_code ) => {
361
359
thread:: sleep ( delay) ;
362
360
attempts += 1 ;
363
361
delay *= 2 ;
364
362
}
365
- Ok ( resp) => return Ok ( resp) ,
366
- Err ( e) => return Err ( Error :: Minreq ( e) ) ,
363
+ resp => return Ok ( resp) ,
367
364
}
368
365
}
369
366
}
You can’t perform that action at this time.
0 commit comments