Commit a723e896 authored by David Golden's avatar David Golden

make t::SimpleCookieJar slightly more corret

Allows testing how multiple cookie headers are
handled
parent c6eae9e1
......@@ -9,15 +9,21 @@ sub new {
}
sub add {
my ($self, $url, $cookies) = @_;
my ($self, $url, $cookie) = @_;
$self->{$url} = $cookies;
my ($kv) = split qr/;/, $cookie;
my ($k, $v) = split qr/\s*=\s*/, $kv, 2;
$self->{$url}{$k} = $v;
}
sub cookie_header {
my ($self, $url) = @_;
return $self->{$url};
my $cookies = $self->{$url}
or return '';
return join( "; ", map{ "$_=$cookies->{$_}" } sort keys %$cookies );
}
1;
......@@ -22,7 +22,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue; domain=example.com; path=/
Cookies: cname=cvalue
----------
HTTP/1.1 200 OK
......
......@@ -22,7 +22,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue01; domain=example.com; path=/
Cookies: cname=cvalue01
----------
HTTP/1.1 200 OK
......@@ -40,7 +40,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue02; domain=example.com; path=/
Cookies: cname=cvalue02
----------
HTTP/1.1 200 OK
......
......@@ -22,7 +22,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue01; domain=example.com; path=/
Cookies: cname=cvalue01
----------
HTTP/1.1 200 OK
......@@ -57,7 +57,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue02; domain=example.com; path=/
Cookies: cname=cvalue02
----------
HTTP/1.1 200 OK
......@@ -75,7 +75,7 @@ GET /index02.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue03; domain=example.com; path=/
Cookies: cname=cvalue03
----------
HTTP/1.1 200 OK
......
......@@ -7,7 +7,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue05; domain=example.com; path=/
Cookies: cname=cvalue05
----------
HTTP/1.1 200 OK
......@@ -25,7 +25,7 @@ GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname=cvalue06; domain=example.com; path=/
Cookies: cname=cvalue06
----------
HTTP/1.1 200 OK
......
url
http://example.com/index.html
----------
GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
----------
HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 00:00:00 GMT
Set-Cookie: cname1=cvalue01; domain=example.com; path=/
Content-Type: text/plain
Content-Length: 44
abcdefghijklmnopqrstuvwxyz1234567890abcdef
----------
url
http://example.com/index.html
----------
GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname1=cvalue01
----------
HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 00:00:00 GMT
Set-Cookie: cname2=cvalue02; domain=example.com; path=/
Content-Type: text/plain
Content-Length: 44
abcdefghijklmnopqrstuvwxyz1234567890abcdef
----------
url
http://example.com/index.html
----------
GET /index.html HTTP/1.1
Host: example.com
Connection: close
User-Agent: HTTP-Tiny/VERSION
Cookies: cname1=cvalue01; cname2=cvalue02
----------
HTTP/1.1 200 OK
Date: Sat, 02 Mar 2013 00:00:00 GMT
Content-Type: text/plain
Content-Length: 44
abcdefghijklmnopqrstuvwxyz1234567890abcdef
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment