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 {
432432 let mut attempts = 0 ;
433433
434434 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 ( ) ) => {
440437 task:: sleep ( delay) . await ;
441438 attempts += 1 ;
442439 delay *= 2 ;
443440 }
444- Ok ( resp) => return Ok ( resp) ,
445- Err ( e) => return Err ( Error :: Reqwest ( e) ) ,
441+ resp => return Ok ( resp) ,
446442 }
447443 }
448444 }
449445}
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 {
354354 let mut attempts = 0 ;
355355
356356 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 ) => {
361359 thread:: sleep ( delay) ;
362360 attempts += 1 ;
363361 delay *= 2 ;
364362 }
365- Ok ( resp) => return Ok ( resp) ,
366- Err ( e) => return Err ( Error :: Minreq ( e) ) ,
363+ resp => return Ok ( resp) ,
367364 }
368365 }
369366 }
You can’t perform that action at this time.
0 commit comments