diff options
author | Nathan Gass | 2015-06-23 14:01:32 +0200 |
---|---|---|
committer | Nathan Gass | 2015-06-23 14:01:32 +0200 |
commit | 231b8a0ecee301699e202988d88de077a95ac0f9 (patch) | |
tree | 89d5f17f1139447fddffad9b79bdee4f85f212a9 /it_url.class | |
parent | 4d56582966bc741c579712bd904aee9680af8f62 (diff) | |
download | itools-231b8a0ecee301699e202988d88de077a95ac0f9.tar.gz itools-231b8a0ecee301699e202988d88de077a95ac0f9.tar.bz2 itools-231b8a0ecee301699e202988d88de077a95ac0f9.zip |
better error handling, port last commit to request_curl
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/it_url.class b/it_url.class index 5973887..c465f13 100644 --- a/it_url.class +++ b/it_url.class @@ -380,13 +380,18 @@ function request($p=array()) } @fclose($fp); - } + } else + $this->errstr = $errstr; - if (time() >= $endtime) + if (time() >= $endtime) { $result = $this->result = false; + $errstr = $this->errstr = "totaltimeout reached"; + } - if ($p['maxlength'] && (strlen($this->data) + $len > $p['maxlength'])) + if ($p['maxlength'] && (strlen($this->data) + $len > $p['maxlength'])) { $result = $this->result = false; + $errstr = $this->errstr = "maxlength reached"; + } if ($result === false && $p['safety'] == 1) it::error(array('title' => "problem (timeout?) getting $url->url " . $errstr) + (array)$p['it_error']); @@ -461,21 +466,24 @@ function request_curl($p=array()) EDC('curlinfo', curl_getinfo($curl)); - if ($got === false && $p['safety'] == 1) - it::error(array('title' => "problem getting $url->url with curl: " . curl_error($curl)) + (array)$p['it_error']); - if ($got) { list($url->header, $url->data) = explode("\r\n\r\n", $got, 2); $url->header .= "\r\n\r\n"; $url->parse_http_header($url->header); - if ($p['maxlength'] && (strlen($this->data) > $p['maxlength'])) - $result = false; - else + if ($p['maxlength'] && (strlen($this->data) > $p['maxlength'])) { + $result = $this->result = false; + $errstr = $this->errstr = "maxlength reached"; + } else $result =& $url->data; - } else - $result = false; + } else { + $result = $this->result = false; + $errstr = $this->errstr = curl_error($curl); + } + + if ($got === false && $p['safety'] == 1) + it::error(array('title' => "problem getting $url->url with curl: " . curl_error($curl)) + (array)$p['it_error']); return $result; } |