You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by pg...@apache.org on 2006/01/03 04:44:24 UTC
svn commit: r365530 - in /httpd/apreq/trunk: CHANGES
glue/perl/lib/Apache2/Cookie.pm glue/perl/t/apreq/cookie.t
glue/perl/t/response/TestApReq/cookie.pm
Author: pgollucci
Date: Mon Jan 2 19:44:20 2006
New Revision: 365530
URL: http://svn.apache.org/viewcvs?rev=365530&view=rev
Log:
Fix Apache2::Cookie->cookies() to comply with its documentation
in particular
@names = $j->cookies(); # all cookie names
Reported By: Jeff <mo...@aquabolt.com>
Pointy Hat: joes
Also, add some associated tests
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm
httpd/apreq/trunk/glue/perl/t/apreq/cookie.t
httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
Modified: httpd/apreq/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/CHANGES?rev=365530&r1=365529&r2=365530&view=diff
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Mon Jan 2 19:44:20 2006
@@ -4,6 +4,9 @@
@section v2_07 Changes with libapreq2-2.07
+- Perl API [Philip M. Gollucci]
+ Fix Apache2::Cookie->cookies() to comply with its documentation
+
- C API [Philip M. Gollucci]
Use the APREQ_DEFAULT_READ_LIMIT constant for the read_limit
Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm?rev=365530&r1=365529&r2=365530&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm (original)
+++ httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm Mon Jan 2 19:44:20 2006
@@ -93,7 +93,11 @@
package Apache2::Cookie::Jar;
use APR::Request::Apache2;
push our @ISA, qw/APR::Request::Apache2/;
-sub cookies { Apache2::Cookie->fetch(@_) }
+sub cookies {
+ return Apache2::Cookie->fetch(@_) if @_ == 2;
+ my $cookies = Apache2::Cookie->fetch(@_);
+ return wantarray ? keys %$cookies : $cookies;
+}
*Apache2::Cookie::Jar::status = *APR::Request::jar_status;
sub new {
Modified: httpd/apreq/trunk/glue/perl/t/apreq/cookie.t
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/apreq/cookie.t?rev=365530&r1=365529&r2=365530&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/apreq/cookie.t (original)
+++ httpd/apreq/trunk/glue/perl/t/apreq/cookie.t Mon Jan 2 19:44:20 2006
@@ -6,7 +6,7 @@
use Apache::TestUtil;
use Apache::TestRequest qw(GET_BODY GET_HEAD);
-plan tests => 9, have_lwp;
+plan tests => 12, have_lwp;
require HTTP::Cookies;
@@ -91,4 +91,61 @@
my ($header) = GET_HEAD("$location?test=$test&key=$key",
Cookie => $cookie) =~ /^#Set-Cookie2:\s+(.+)/m;
ok t_cmp($header, qq{$key="$value"; Version=1; path="$location"}, $test);
+}
+
+{
+ my $test = 'cookies';
+ my $key = 'first';
+ my $cookie1 = qq{\$Version="1"; one="1"};
+ my $cookie2 = qq{\$Version="1"; two="2"};
+ my $cookie3 = qq{\$Version="1"; three="3"};
+ my $cookie4 = qq{\$Version="1"; two="22"};
+ my $value = qq{one="1"; Version=1};
+
+ my $str = GET_BODY("$location?test=$test&key=$key",
+ Cookie => $cookie1,
+ Cookie => $cookie2,
+ Cookie => $cookie3,
+ Cookie => $cookie4,
+ );
+
+ ok t_cmp($str, $value, $test);
+}
+
+{
+ my $test = 'cookies';
+ my $key = 'all';
+ my $cookie1 = qq{\$Version="1"; one="1"};
+ my $cookie2 = qq{\$Version="1"; two="2"};
+ my $cookie3 = qq{\$Version="1"; three="3"};
+ my $cookie4 = qq{\$Version="1"; two="22"};
+ my $value = qq{two="2"; Version=1 two="22"; Version=1};
+
+ my $str = GET_BODY("$location?test=$test&key=$key",
+ Cookie => $cookie1,
+ Cookie => $cookie2,
+ Cookie => $cookie3,
+ Cookie => $cookie4,
+ );
+
+ ok t_cmp($str, $value, $test);
+}
+
+{
+ my $test = 'cookies';
+ my $key = 'name';
+ my $cookie1 = qq{\$Version="1"; one="1"};
+ my $cookie2 = qq{\$Version="1"; two="2"};
+ my $cookie3 = qq{\$Version="1"; three="3"};
+ my $cookie4 = qq{\$Version="1"; two="22"};
+ my $value = qq{one two three two};
+
+ my $str = GET_BODY("$location?test=$test&key=$key",
+ Cookie => $cookie1,
+ Cookie => $cookie2,
+ Cookie => $cookie3,
+ Cookie => $cookie4,
+ );
+
+ ok t_cmp($str, $value, $test);
}
Modified: httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm?rev=365530&r1=365529&r2=365530&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm (original)
+++ httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm Mon Jan 2 19:44:20 2006
@@ -19,7 +19,23 @@
my $test = $req->APR::Request::args('test');
my $key = $req->APR::Request::args('key');
- if ($key and $cookies{$key}) {
+ if ($test eq 'cookies') {
+ my $jar = Apache2::Cookie::Jar->new($r);
+
+ if ($key eq 'first') {
+ my $cookie = $jar->cookies('one');
+ $r->print($cookie->as_string());
+ }
+ elsif ($key eq 'all') {
+ my @cookies = $jar->cookies('two');
+ $r->print(join ' ', map { $_->as_string() } @cookies);
+ }
+ else {
+ my @names = $jar->cookies();
+ $r->print(join ' ', map { $_ } @names);
+ }
+ }
+ elsif ($key and $cookies{$key}) {
if ($test eq "bake") {
$cookies{$key}->bake($r);
}