diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2019-11-17 20:45:02 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2019-11-17 20:45:02 +0100 |
commit | 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 (patch) | |
tree | 4d541098d751d5a9acf8c12f6fb9f308ace066ac /vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php | |
download | flyspray-8df3db566a3a937b45ebf11adb90d265e6f5e2d4.tar.xz |
initial checking of customized version 1.0rc9
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php')
-rw-r--r-- | vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php b/vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php new file mode 100644 index 0000000..9c63a14 --- /dev/null +++ b/vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff/HttpBackoffStrategy.php @@ -0,0 +1,30 @@ +<?php + +namespace Guzzle\Plugin\Backoff; + +use Guzzle\Http\Message\RequestInterface; +use Guzzle\Http\Message\Response; +use Guzzle\Http\Exception\HttpException; + +/** + * Strategy used to retry HTTP requests based on the response code. + * + * Retries 500 and 503 error by default. + */ +class HttpBackoffStrategy extends AbstractErrorCodeBackoffStrategy +{ + /** @var array Default cURL errors to retry */ + protected static $defaultErrorCodes = array(500, 503); + + protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null) + { + if ($response) { + //Short circuit the rest of the checks if it was successful + if ($response->isSuccessful()) { + return false; + } else { + return isset($this->errorCodes[$response->getStatusCode()]) ? true : null; + } + } + } +} |