diff options
author | Urban Müller | 2020-08-10 16:19:25 +0200 |
---|---|---|
committer | Urban Müller | 2020-08-10 16:19:25 +0200 |
commit | 7eac01f1c0327fb5b16a6d2581cae31fb27bdc11 (patch) | |
tree | 86612d3534b1a98855752999e3cc1212c9352ff2 /it_url.class | |
parent | 1eba6c6d52660ae9209598423de357e5ea939030 (diff) | |
download | itools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.tar.gz itools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.tar.bz2 itools-7eac01f1c0327fb5b16a6d2581cae31fb27bdc11.zip |
use positive list for retry status codes
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 5 |
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']) { |