diff options
author | Christian A. Weber | 2015-01-19 20:15:58 +0100 |
---|---|---|
committer | Christian A. Weber | 2015-01-19 20:15:58 +0100 |
commit | 2b889af3ab520e8c20881cb840fbfba5c27e87d3 (patch) | |
tree | 36083518993fdf45ee50678a3a28f5ecf01f6a3b | |
parent | 4b2800e5ae97e97a9ee1d6db91b7f8ab78be7b25 (diff) | |
download | itools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.tar.gz itools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.tar.bz2 itools-2b889af3ab520e8c20881cb840fbfba5c27e87d3.zip |
request() stores cookies set by server in $this->cookies[]
-rw-r--r-- | it_url.class | 5 |
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']; |