From af3fa671c551d25fcf29762e8e46fe4173b0514e Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Tue, 2 Apr 2019 18:59:51 +0200 Subject: add option noresults and debug handler feature in it_url::get_multi --- it_url.class | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'it_url.class') diff --git a/it_url.class b/it_url.class index 7b364d2..e3139c8 100644 --- a/it_url.class +++ b/it_url.class @@ -310,6 +310,7 @@ function request($p=array()) * @param $p['totaltimeout']: timeout for the whole function call (fractions allowed) * @param $p['headers']: optional array of HTTP headers to send * @param $p['parallel']: max number of parallel requests + * @param $p['noresults']: do not keep results around * @return array of contents (or false for errors like timesou) of resulting page using same * keys as the urls input array, considering redirects, excluding headers */ @@ -375,15 +376,16 @@ function get_multi($p=null) $closehandle($key); EDC('reqtimings', $key, $info['result'], (gettimeofday(true) - $start) * 1000); - if ($info['result'] == CURLE_OK) - $results_unordered[$key] = $content; - else if($retries[$key]++ < $p['retries']) + if ($info['result'] == CURLE_OK) { + if (!$p['noresults']) + $results_unordered[$key] = $content; + } else if($retries[$key]++ < $p['retries']) $addhandle($key); else $results_unordered[$key] = false; - if (($handler = $urls[$keys[$info['handle']]]['handler'])) - $abort = $handler($info['result'], $results_unordered[$key]); + if (($handler = $urls[$key]['handler'])) + $abort = $handler($info['result'], $content); if (!$abort && count($handles) < $parallel && $tofetch) $addhandle(array_shift($tofetch)); @@ -397,7 +399,7 @@ function get_multi($p=null) $closehandle($key); curl_multi_close($mh); - return it::filter_keys($results_unordered, array_keys($urls), ['reorder' => true]); + return $p['noresults'] ? null : it::filter_keys($results_unordered, array_keys($urls), ['reorder' => true]); } /** -- cgit v1.2.3