diff options
-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']) { |