summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2019-04-02 18:59:51 +0200
committerNathan Gass2019-04-02 18:59:51 +0200
commitaf3fa671c551d25fcf29762e8e46fe4173b0514e (patch)
tree7032064835880ba885a40ade89f97ccea9d46444
parent09e994d923af3c9f72792b12c6bff1f797084a8c (diff)
downloaditools-af3fa671c551d25fcf29762e8e46fe4173b0514e.tar.gz
itools-af3fa671c551d25fcf29762e8e46fe4173b0514e.tar.bz2
itools-af3fa671c551d25fcf29762e8e46fe4173b0514e.zip
add option noresults and debug handler feature in it_url::get_multi
-rw-r--r--it_url.class14
1 files changed, 8 insertions, 6 deletions
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]);
}
/**