src/Factory.php
private static function retryDecider()
    {
        return function (
            $retries,
            Request $request,
            Response $response = null,
            RequestException $exception = null
        ) {
            // Limit the number of retries to 10
            if ($retries >= 10) {
                return false;
            }

            // Retry connection exceptions
            if ($exception instanceof ConnectException) {
                return true;
            }

            if ($response) {
                // Retry on server errors or overload
                $statusCode = $response->getStatusCode();
                if (429 == $statusCode || 504 == $statusCode || 503 == $statusCode || 502 == $statusCode) {
                    return true;
                }
            }

            return false;
        };
    }
private static function retryDecider()
    {
        return function (
            $retries,
            Request $request,
            Response $response = null,
            RequestException $exception = null
        ) {
            // Limit the number of retries to 10
            if ($retries >= 10) {
                return false;
            }

            // Retry connection exceptions
            if ($exception instanceof ConnectException) {
                return true;
            }

            if ($response) {
                // Retry on server errors or overload
                $statusCode = $response->getStatusCode();
                if (429 == $statusCode || 504 == $statusCode || 503 == $statusCode || 502 == $statusCode) {
                    return true;
                }
            }

            return false;
        };
    }
private static function retryDecider ( ) { return function ( $ retries , Request $ request , Response $ response = null , RequestException $ exception = null ) { // Limit the number of retries to 10 if ( $ retries >= 10 ) { return false ; } // Retry connection exceptions if ( $ exception instanceof ConnectException ) { return true ; } if ( $ response ) { // Retry on server errors or overload $ statusCode = $ response -> getStatusCode ( ) ; if ( 429 == $ statusCode || 504 == $ statusCode || 503 == $ statusCode || 502 == $ statusCode ) { return true ; } } return false ; } ; }
Returns a Closure for the Retry Middleware to decide if it should retry the request when it failed.

@return \Closure
Returns a Closure for the Retry Middleware to decide if it should retry the request when it failed .