From fef9b217cbdb76103112995d4b94e95468826562 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 15 Apr 2014 14:26:21 +0200 Subject: support setting of it::error params in it_url::get --- it_url.class | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/it_url.class b/it_url.class index 3888b17..e961b4c 100644 --- a/it_url.class +++ b/it_url.class @@ -220,15 +220,16 @@ function is_reachable($timeout = 5) * If the protocol is not http, only features of get_multi are supported. * * @param $p parameter array with the following keys - * @param $p['url']: url to get, defaults to constructor URL - * @param $p['headers']: optional array of HTTP headers to send - * @param $p['timeout']: timeout per read in seconds, defaults to 5. fractions allowed. silent, see $p['safety'] - * @param $p['safety']: set to 1 to generate an it::error in case of timeout - * @param $p['totaltimeout']: timeout for the whole function call - * @param $p['maxlength']: maximum length of response - * @param $p['filemtime']: Add HTTP header to only fetch when newer than this, otherwise return true instead of data - * @param $p['data']: POST data array with key-value pairs - * @param $p['retries']: Number of retries if download fails, default 1 + * @param $p['url'] url to get, defaults to constructor URL + * @param $p['headers'] optional array of HTTP headers to send + * @param $p['safety'] set to 1 to generate an it::error in case of timeout + * @param $p['it_error'] extra arguments given to it_error if safety is on an an error occurs + * @param $p['timeout'] timeout per read in seconds, defaults to 5. fractions allowed. silent, see $p['safety'] + * @param $p['totaltimeout'] timeout for the whole function call + * @param $p['maxlength'] maximum length of response + * @param $p['filemtime'] Add HTTP header to only fetch when newer than this, otherwise return true instead of data + * @param $p['data']: POST data array with key-value pairs + * @param $p['retries']: Number of retries if download fails, default 1 * @return contents of resulting page, considering redirects, excluding headers, or false on error */ function get($p=null, $timeout=5) @@ -375,7 +376,7 @@ function request($p=array()) $result = false; if ($result === false && $p['safety'] == 1) - it::error("problem (timeout?) getting $url->url " . $errstr); + it::error(array('title' => "problem (timeout?) getting $url->url " . $errstr) + (array)$p['it_error']); if ($p['maxlength'] && (strlen($this->data) + $len > $p['maxlength'])) $result = false; -- cgit v1.2.3