diff options
author | Urban Müller | 2017-08-11 17:17:25 +0200 |
---|---|---|
committer | Urban Müller | 2017-08-11 17:17:25 +0200 |
commit | d3d3da3103aa902764c831eb104569db2c22c9bb (patch) | |
tree | 851a915b65114c5a4d666bc2e495a9b8bb324be3 /it_url.class | |
parent | da34c035df9a140bbdfb40ac6ebe7354da3f5494 (diff) | |
download | itools-d3d3da3103aa902764c831eb104569db2c22c9bb.tar.gz itools-d3d3da3103aa902764c831eb104569db2c22c9bb.tar.bz2 itools-d3d3da3103aa902764c831eb104569db2c22c9bb.zip |
better err msg
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 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; } |