summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
authorChristian A. Weber2015-01-19 20:15:58 +0100
committerChristian A. Weber2015-01-19 20:15:58 +0100
commit2b889af3ab520e8c20881cb840fbfba5c27e87d3 (patch)
tree36083518993fdf45ee50678a3a28f5ecf01f6a3b /it_url.class
parent4b2800e5ae97e97a9ee1d6db91b7f8ab78be7b25 (diff)
downloaditools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.tar.gz
itools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.tar.bz2
itools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.zip
request() stores cookies set by server in $this->cookies[]
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class5
1 files changed, 4 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class
index 5997141..c605c91 100644
--- a/it_url.class
+++ b/it_url.class
@@ -37,6 +37,7 @@ class it_url
var $page_read; /* true if page read */
var $title; /* Page title or empty */
var $description; /* Page description or empty */
+ var $cookies; /* key => values of cookies from server */
var $headers; /* Headers of page fetched by get() */
var $data; /* Data part, even if return code is not 200 */
@@ -284,6 +285,8 @@ function parse_http_header($header)
$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))
+ $this->cookies[$cookie[1]] = $cookie[2];
}
}
@@ -297,7 +300,7 @@ function request($p=array())
$url->result = $result = false;
unset($url->data);
- $url->headers = array();
+ $url->headers = $url->cookies = array();
$p['timeout'] = min($p['timeout'], $p['totaltimeout']); # No operation may be longer than totaltimeout
$endtime = time() + $p['totaltimeout'];