Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/AnyEvent/HTTP/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,14 @@ sub incoming {
$lastkey = lc $1;
$h{ $lastkey } = exists $h{ $lastkey } ? $h{ $lastkey }.','.$2: $2;
#warn "Captured header $lastkey = '$2'";
my $v = $2;
if ( defined $3 ) {
pos(my $v = $2) = $-[3] - $-[2];
#warn "scan ';'";
$h{ $lastkey . '+' . lc($1) } = ( defined $2 ? do { my $x = $2; $x =~ s{\\(.)}{$1}gs; $x } : $3 )
while ( $v =~ m{ \G ; \s* ([^\s=]++)\s*= (?: "((?:[^\\"]++|\\.){0,4096}+)" | ([^;,\s]++) ) \s* }gcxso ); # "
while ( $v =~ m{ \s* ([^\s=]++)\s*= (?: "((?:[^\\"]++|\\.){0,4096}+)" | ([^;,\s]++) ) \s* ;? }gcxso ); # "
$contstate = 1;
} else {
} else {
$h{ $lastkey . '+' . lc($1) } = ( defined $2 ? do { my $x = $2; $x =~ s{\\(.)}{$1}gs; $x } : $3 )
if ( $v =~ m{ \s* ([^\s=]++)\s*= (?: "((?:[^\\"]++|\\.){0,4096}+)" | ([^;,\s]++) ) \s* ;? }xso ); # "
$contstate = 0;
}
}
Expand Down
19 changes: 18 additions & 1 deletion t/basic.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env perl

use Test::More tests => 224;
use Test::More tests => 244;
use Data::Dumper;
use FindBin;
use lib "$FindBin::Bin/..";
Expand Down Expand Up @@ -291,6 +291,23 @@
[["GET /test1 HTTP/1.1\nHost:localhost\nConnection:keep-alive\n\n"], 200, { 'content-length' => 0 }, "" ],
if ALL;

test_server {
my $s = shift;
my $r = shift;
return (
$r->method eq 'GET' ? 200 : 400,
"x=".$r->headers->{'cookie+x'}.",y=".$r->headers->{'cookie+y'},
headers => {
},
);
} 'Cookies parsing',
[["GET /test1 HTTP/1.1\nCookie: x=1\n\n"], 200, { }, "x=1,y=" ],
[["GET /test2 HTTP/1.1\nCookie: x=1;y=2\n\n"], 200, { }, "x=1,y=2" ],
[["GET /test2 HTTP/1.1\nCookie: x=\"1\";y=2\n\n"], 200, { }, "x=1,y=2" ],
[["GET /test2 HTTP/1.1\nCookie: x=1;y=\"2\"\n\n"], 200, { }, "x=1,y=2" ],
[["GET /test2 HTTP/1.1\nCookie: x=\"1\";y=\"2\"\n\n"], 200, { }, "x=1,y=2" ],
if ALL;

}

done_testing();