summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class9
1 files changed, 6 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class
index 772b7d1..cfeaa1d 100644
--- a/it_url.class
+++ b/it_url.class
@@ -163,7 +163,7 @@ function _get($p = [])
return $result;
}
-function retry_warranted($result, $status)
+static function retry_warranted($result, $status)
{
return $result ? it::match(self::$forceretry, $status) : !it::match('^(204|4..)$', $status);
}
@@ -466,7 +466,10 @@ static function get_multi($p=null)
{
$key = $keys[(int)$info['handle']];
$content = curl_multi_getcontent($info['handle']);
- if (isset($p['postprocess']))
+ $status = curl_getinfo($handles[$key], CURLINFO_RESPONSE_CODE);
+ if ($status >= 400 && (!$p['body_on_fail'] || $p['keepfailed']))
+ $content = false;
+ else if (isset($p['postprocess']))
$content = $p['postprocess']($content, ['it_error' => $retries[$key] < $p['retries'] ? false : (array)$p['it_error'] + ['title' => "invalid content from " . $urls[$key]]]);
EDC('reqtimings', $key, $info['result'], (gettimeofday(true) - $start) * 1000);
@@ -475,7 +478,7 @@ static function get_multi($p=null)
if (!$p['noresults'])
$results_unordered[$key] = $content;
- if (it::match(self::$forceretry, curl_getinfo($handles[$key], CURLINFO_RESPONSE_CODE)) && $retries[$key]++ < $p['retries'])
+ if (self::retry_warranted($content, $status) && $retries[$key]++ < $p['retries'])
{
$sleepuntils[$key] = microtime(true) + $p['retrysleep'];
}