protected function shouldRetryHttpResponse(array $options, ResponseInterface $response)
    {
        $statuses = array_map('\intval', (array) $options['retry_on_status']);

        switch (true) {
            case $options['retry_enabled'] === false:
                return false;

            case $this->countRemainingRetries($options) === 0:
                return false;

            // No Retry-After header, and it is required?  Give up
            case (! $response->hasHeader('Retry-After') && $options['retry_only_if_retry_after_header']):
                return false;

            // Conditions met; see if status code matches one that can be retried
            default:
                return \in_array($response->getStatusCode(), $statuses, true);
        }
    }
protected function shouldRetryHttpResponse(array $options, ResponseInterface $response)
    {
        $statuses = array_map('\intval', (array) $options['retry_on_status']);

        switch (true) {
            case $options['retry_enabled'] === false:
                return false;

            case $this->countRemainingRetries($options) === 0:
                return false;

            // No Retry-After header, and it is required?  Give up
            case (! $response->hasHeader('Retry-After') && $options['retry_only_if_retry_after_header']):
                return false;

            // Conditions met; see if status code matches one that can be retried
            default:
                return \in_array($response->getStatusCode(), $statuses, true);
        }
    }
protected function shouldRetryHttpResponse ( array $ options , ResponseInterface $ response ) { $ statuses = array_map ( '\intval' , ( array ) $ options [ 'retry_on_status' ] ) ; switch ( true ) { case $ options [ 'retry_enabled' ] === false : return false ; case $ this -> countRemainingRetries ( $ options ) === 0 : return false ; // No Retry-After header, and it is required?  Give up case ( ! $ response -> hasHeader ( 'Retry-After' ) && $ options [ 'retry_only_if_retry_after_header' ] ) : return false ; // Conditions met; see if status code matches one that can be retried default : return \ in_array ( $ response -> getStatusCode ( ) , $ statuses , true ) ; } }
Check to see if a request can be retried

This checks two things:

1. The response status code against the status codes that should be retried
2. The number of attempts made thus far for this request

@param array $options
@param ResponseInterface|null $response
@return bool  TRUE if the response should be retried, FALSE if not
Check to see if a request can be retried