summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class5
1 files changed, 3 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class
index 637990c..91dfbf4 100644
--- a/it_url.class
+++ b/it_url.class
@@ -150,7 +150,7 @@ function _get($p = [])
usleep($p['fetchsleep'] * 1000000);
if ($p['assoc'])
- $result = $result !== false ? [ 'status' => $this->result, 'data' => $this->data, 'headers' => $this->headers, 'cookies' => $this->cookies, 'errstr' => $this->errstr ] : [];
+ $result = [ 'status' => intval($this->result) ?: 503, 'data' => $result !== false ? $this->data : null, 'headers' => $this->headers, 'cookies' => $this->cookies, 'errstr' => $this->errstr ];
EDC('curlinfo', $this->result, $this->headers, $this->cookies, $this->errstr);
@@ -615,7 +615,8 @@ static function get_cache($p = array())
EDC('getcache', "new", $filemtime, $p['url'], $path);
$url = new it_url;
- if ($data = $url->_get($p + ['checkonly' => true, 'filemtime' => EDC('nocache') ? null : $filemtime])) # => true means not modified (no new data fetched)
+ $response = $url->_get($p + ['checkonly' => true, 'filemtime' => EDC('nocache') ? null : $filemtime]);
+ if ($data = $p['assoc'] ? $response['data'] : $response) # $data === true means not modified (no new data fetched)
{
$success = true;
$isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? it::json_encode($data) : $data);