summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2020-08-10 16:19:25 +0200
committerUrban Müller2020-08-10 16:19:25 +0200
commit7eac01f1c0327fb5b16a6d2581cae31fb27bdc11 (patch)
tree86612d3534b1a98855752999e3cc1212c9352ff2
parent1eba6c6d52660ae9209598423de357e5ea939030 (diff)
downloaditools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.tar.gz
itools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.tar.bz2
itools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.zip
use positive list for retry status codes
-rw-r--r--it_url.class5
1 files changed, 3 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class
index 51cf9fb..fa58d88 100644
--- a/it_url.class
+++ b/it_url.class
@@ -40,6 +40,7 @@ class it_url
var $header; /* http header */
var $errstr; /* request error string */
+ static $retryable = "^(5..)$";
/**
* Constructor: canonicalize an URL
@@ -136,7 +137,7 @@ function _get($p = [], $timeout = null)
$result = $this->request($p + ['followlocation' => true]);
$result = self::_postprocess($result, $p);
- if ($p['retries'] > 0 && ((!$result && !it::match('^(204|4..)$', $this->result)) || it::match('^(5..)$', $this->result)))
+ if ($p['retries'] > 0 && ((!$result && !it::match('^(204|4..)$', $this->result)) || it::match(self::$retryable, $this->result)))
{
usleep($p['retrysleep']*1000000);
$result = $this->_get(array('retries' => $p['retries'] - 1) + $p);
@@ -418,7 +419,7 @@ static function get_multi($p=null)
if (is_array($urls[$key]) && ($handler = $urls[$key]['handler']))
$abort = $handler($info['handle'], $content);
- if (!it::match('^(2..|4..)$', curl_getinfo($handles[$key], CURLINFO_RESPONSE_CODE)) && $retries[$key]++ < $p['retries'])
+ if (it::match(self::$retryable, curl_getinfo($handles[$key], CURLINFO_RESPONSE_CODE)) && $retries[$key]++ < $p['retries'])
$sleepuntils[$key] = microtime(true) + $p['retrysleep'];
$closehandle($key);
} else if($retries[$key]++ < $p['retries']) {