1: <?php
2:
3: namespace Guzzle\Plugin\Backoff;
4:
5: use Guzzle\Http\Message\RequestInterface;
6: use Guzzle\Http\Message\Response;
7: use Guzzle\Http\Exception\HttpException;
8: use Guzzle\Http\Exception\CurlException;
9:
10: 11: 12:
13: class CurlBackoffStrategy extends AbstractErrorCodeBackoffStrategy
14: {
15: 16: 17:
18: protected static $defaultErrorCodes = array(
19: CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_WRITE_ERROR, CURLE_READ_ERROR,
20: CURLE_OPERATION_TIMEOUTED, CURLE_SSL_CONNECT_ERROR, CURLE_HTTP_PORT_FAILED, CURLE_GOT_NOTHING,
21: CURLE_SEND_ERROR, CURLE_RECV_ERROR
22: );
23:
24: 25: 26:
27: protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
28: {
29: if ($e && $e instanceof CurlException) {
30: return isset($this->errorCodes[$e->getErrorNo()]) ? true : null;
31: }
32: }
33: }
34: