summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2019-03-01 23:58:25 +0100
committerUrban Müller2019-03-01 23:58:25 +0100
commite26b3afcc798515295a537be76451d31ec173714 (patch)
tree354abf164715a080d36b7d7065e7abb443b7d241
parenta648b594c6a96f050b99eb691c73b41f27d6890b (diff)
downloaditools-e26b3afcc798515295a537be76451d31ec173714.tar.gz
itools-e26b3afcc798515295a537be76451d31ec173714.tar.bz2
itools-e26b3afcc798515295a537be76451d31ec173714.zip
Revert "better name for http status variable" for now
This reverts commit a648b594c6a96f050b99eb691c73b41f27d6890b.
-rw-r--r--it_url.class17
-rwxr-xr-xtest/it_url.t5
2 files changed, 7 insertions, 15 deletions
diff --git a/it_url.class b/it_url.class
index affd38a..7b364d2 100644
--- a/it_url.class
+++ b/it_url.class
@@ -34,9 +34,8 @@ class it_url
var $pass; /* E.g. joshua */
var $cookies; /* key => values of cookies from server */
var $headers; /* Headers of page fetched by get() */
- var $data; /* Data part, even if http status code is not 200 */
- var $result; /* DEPRECATED, see $status */
- var $status; /* HTTP status code of last get() */
+ var $data; /* Data part, even if return code is not 200 */
+ var $result; /* HTTP response code of get() */
var $redir = 0; /* Redirect count */
var $header; /* http header */
var $errstr; /* request error string */
@@ -132,7 +131,7 @@ function get($p=null, $timeout=5)
$result = $url->request($p + ['followlocation' => true]);
- if (!$result && $p['retries'] > 0 && $url->status < 400)
+ if (!$result && $p['retries'] > 0 && $url->result < 400)
{
usleep($p['retrysleep']*1000000);
$result = $url->get(array('retries' => $p['retries'] - 1) + $p);
@@ -151,7 +150,7 @@ function parse_http_header($header)
foreach (explode("\n", trim($header)) as $line) {
$line = trim($line);
if (preg_match('#^(HTTP)\S+\s(\d+)#', $line, $parts)) # Parse result code
- $this->headers[$parts[1]] = $this->status = $parts[2];
+ $this->headers[$parts[1]] = $this->result = $parts[2];
elseif (preg_match('#^([^:]+): (.*)$#', $line, $parts))
$this->headers[$parts[1]] = $parts[2];
if ($parts[1] == 'Set-Cookie' && preg_match('/^([^=]+)=([^;]*)/', $parts[2], $cookie))
@@ -275,15 +274,15 @@ function request($p=array())
$url->parse_http_header($url->header);
if ($p['maxlength'] && (strlen($this->data) > $p['maxlength'])) {
- $result = $this->status = false;
+ $result = $this->result = false;
$this->errstr = "maxlength reached";
- } else if ($p['filemtime'] && ($url->status == 304)) {
+ } else if ($p['filemtime'] && ($url->result == 304)) {
$result = true; # Not modified, success but no data
} else {
$result =& $url->data;
}
} else {
- $result = $this->status = false;
+ $result = $this->result = false;
$this->errstr = trim("(" . curl_errno($curl) . ") " . curl_error($curl));
$this->curlinfo = curl_getinfo($curl);
}
@@ -298,8 +297,6 @@ function request($p=array())
it::error((array)$p['it_error'] + ['title' => "problem getting $url->url with curl: (" . curl_errno($curl) . ") " . curl_error($curl), 'body' => curl_getinfo($curl) + ($p['verbose'] ? ['verbose' => $this->verbose] : [])]);
}
- $url->result = $url->status; # FIXME 2019-06-01 get rid of remaining uses
-
return $result;
}
diff --git a/test/it_url.t b/test/it_url.t
index 4243f33..eb36dd6 100755
--- a/test/it_url.t
+++ b/test/it_url.t
@@ -138,11 +138,6 @@ ok(
'$url->get(\'url\' => url) with url as named arg'
);
is(
- $url->status,
- '200',
- '$url->status = 200'
-);
-is(
$url->result,
'200',
'$url->result = 200'