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);
        }
    }