diff options
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class index 7042598..99fa395 100644 --- a/it_url.class +++ b/it_url.class @@ -215,14 +215,15 @@ function is_reachable($timeout = 5) } /** - * Get simple URL with timeout. Can be called statically + * Get simple URL with timeout and one retry. Can be called statically * * 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 + * @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 @@ -293,7 +294,7 @@ function request($p=array()) $p['timeout'] = min($p['timeout'], $p['totaltimeout']); # No operation may be longer than totaltimeout $endtime = time() + $p['totaltimeout']; - if ($fp = @fsockopen($url->realhostname, $url->port, $dummy_errno, $dummy_errstr, $p['timeout'])) + if ($fp = @fsockopen($url->realhostname, $url->port, $dummy_errno, $errstr, $p['timeout'])) { # urlencode data pairs if is array if (is_array($p['data'])) @@ -373,6 +374,9 @@ function request($p=array()) if (time() >= $endtime) $result = false; + if ($result === false && $p['safety'] == 1) + it::error("problem (timeout?) getting " . $p['url'] . " " . $errstr); + if ($p['maxlength'] && (strlen($this->data) + $len > $p['maxlength'])) $result = false; |