--- lib/CGI.pm 2010-01-29 07:41:54.000000000 -0700
+++ lib/CGI.pm 2010-02-25 13:10:51.000000000 -0700
@@ -1538,7 +1538,7 @@
my($type,$status,$cookie,$target,$expires,$nph,$charset,$attachment,$p3p,@other) =
rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'],
- 'STATUS',['COOKIE','COOKIES'],'TARGET',
+ 'STATUS',['COOKIE','COOKIES','SET-COOKIE'],'TARGET',
'EXPIRES','NPH','CHARSET',
'ATTACHMENT','P3P'],@p);
@@ -1640,7 +1640,7 @@
sub redirect {
my($self,@p) = self_or_default(@_);
my($url,$target,$status,$cookie,$nph,@other) =
- rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIES'],NPH],@p);
+ rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIES','SET-COOKIE'],NPH],@p);
$status = '302 Found' unless defined $status;
$url ||= $self->self_url;
my(@o);
--- t/html.t 2009-09-09 09:28:57.000000000 -0600
+++ t/html.t 2010-02-25 13:09:44.000000000 -0700
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl -w
-use Test::More tests => 33;
+use Test::More tests => 40;
END { ok $loaded; }
use CGI ( ':standard', '-no_debug', '*h3', 'start_table' );
@@ -125,15 +125,47 @@
my $cookie =
cookie( -name => 'fred', -value => [ 'chocolate', 'chip' ], -path => '/' );
-
is $cookie, 'fred=chocolate&chip; path=/', "cookie()";
my $h = header( -Cookie => $cookie );
-
like $h,
qr!^Set-Cookie: fred=chocolate&chip\; path=/${CRLF}Date:.*${CRLF}Content-Type: text/html; charset=ISO-8859-1${CRLF}${CRLF}!s,
"header(-cookie)";
+$h = header( '-set-cookie' => $cookie );
+like $h,
+ qr!^Set-[Cc]ookie: fred=chocolate&chip\; path=/${CRLF}(Date:.*${CRLF})?Content-Type: text/html; charset=ISO-8859-1${CRLF}${CRLF}!s,
+ "header(-set-cookie)";
+
+my $cookie2 =
+ cookie( -name => 'ginger', -value => 'snap' , -path => '/' );
+is $cookie2, 'ginger=snap; path=/', "cookie2()";
+
+$h = header( -cookie => [ $cookie, $cookie2 ] );
+like $h,
+ qr!^Set-Cookie: fred=chocolate&chip\; path=/${CRLF}Set-Cookie: ginger=snap\; path=/${CRLF}(Date:.*${CRLF})?Content-Type: text/html; charset=ISO-8859-1${CRLF}${CRLF}!s,
+ "header(-cookie=>[cookies])";
+
+$h = header( '-set-cookie' => [ $cookie, $cookie2 ] );
+like $h,
+ qr!^Set-Cookie: fred=chocolate&chip\; path=/${CRLF}Set-Cookie: ginger=snap\; path=/${CRLF}(Date:.*${CRLF})?Content-Type: text/html; charset=ISO-8859-1${CRLF}${CRLF}!s,
+ "header(-set-cookie=>[cookies])";
+
+$h = redirect('
http://elsewhere.org/');
+like $h,
+ qr!Status: 302 Found${CRLF}Location:
http://elsewhere.org/!s,
+ "redirect";
+
+$h = redirect(-url=>'
http://elsewhere.org/', -cookie=>[$cookie,$cookie2]);
+like $h,
+ qr!Status: 302 Found${CRLF}Set-[Cc]ookie: \Q$cookie\E${CRLF}Set-[Cc]ookie: \Q$cookie2\E${CRLF}(Date:.*${CRLF})?Location:
http://elsewhere.org/!s,
+ "redirect with cookies";
+
+$h = redirect(-url=>'
http://elsewhere.org/', '-set-cookie'=>[$cookie,$cookie2]);
+like $h,
+ qr!Status: 302 Found${CRLF}Set-[Cc]ookie: \Q$cookie\E${CRLF}Set-[Cc]ookie: \Q$cookie2\E${CRLF}(Date:.*${CRLF})?Location:
http://elsewhere.org/!s,
+ "redirect with set-cookies";
+
is start_h3, '<h3>';
is end_h3, '</h3>';