From d3d3da3103aa902764c831eb104569db2c22c9bb Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 11 Aug 2017 17:17:25 +0200 Subject: better err msg --- it_url.class | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'it_url.class') diff --git a/it_url.class b/it_url.class index 61f4475..ce98547 100644 --- a/it_url.class +++ b/it_url.class @@ -218,11 +218,12 @@ function request($p=array()) $headers .= "$header: $value\r\n"; } + $lastio = microtime(true); stream_set_timeout($fp, intval($p['timeout']), intval(($p['timeout']*1000000)%1000000)); @fputs($fp, "$method /$url->path HTTP/1.0\r\n$headers\r\n$data"); $url->header = ''; - while (!feof($fp) && ($origline = @fgets($fp, 10240)) && (trim($origline)) && (time() < $endtime)) + while (!feof($fp) && ($lastio = microtime(true)) &&($origline = @fgets($fp, 10240)) && (trim($origline)) && (time() < $endtime)) { $url->header .= $origline; $origline = ''; @@ -234,7 +235,7 @@ function request($p=array()) { if ($url->headers['Transfer-Encoding'] == "chunked") # Bogus HTTP/1.1 chunked answer from server (e.g. Wordpress/Apache2/PHP5) { - while (($len = hexdec(fgets($fp))) && (!$p['maxlength'] || strlen($url->data) + $len <= $p['maxlength'])) + while (($lastio = microtime(true)) && ($len = hexdec(fgets($fp))) && (!$p['maxlength'] || strlen($url->data) + $len <= $p['maxlength'])) { $chunk = ""; @@ -247,7 +248,10 @@ function request($p=array()) else { while (!feof($fp) && (time() < $endtime) && (!$p['maxlength'] || strlen($url->data) <= $p['maxlength'])) + { + $lastio = microtime(true); $url->data .= @fread($fp, 20480); + } } if ($p['filemtime'] && ($url->result == 304)) @@ -271,7 +275,7 @@ function request($p=array()) } if ($result === false && $p['retries'] <= 0) - it::error((array)$p['it_error'] + ['title' => "problem (" . ($errstr ?: "timeout?") . ") getting $url->url "]); + it::error((array)$p['it_error'] + ['title' => "problem (" . ($errstr ?: ($p['timeout'] && microtime(true) - $lastio > $p['timeout'] ? "timeout " . $p['timeout'] : "unknown")) . ") getting $url->url "]); return $result; } -- cgit v1.2.3