Cookies in Dancer 1.3011
When i try to set several cookies, i have trouble: only 1 cookie was set: get '/' => sub { set_cookie('test' => 'test'); set_cookie('test1' => 'test1'); ... } wget -S http://172.20.124.111:3000/ --14:22:48-- http://172.20.124.111:3000/ => `index.html' Connecting to 172.20.124.111:3000... connected. HTTP request sent, awaiting response... HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: test1=test1; path=/; HttpOnly X-Powered-By: Perl Dancer 1.3011 The problem, as i can see, is in the Renderer.pm, function response_with_headers. With patch: --- Renderer.pm 2011-02-22 14:03:43.000000000 +0200 +++ Renderer.pm.new 2011-02-22 13:57:38.000000000 +0200 @@ -55,12 +55,14 @@ $response->header('X-Powered-By' => "Perl Dancer ${Dancer::VERSION}"); # add cookies + my @c = (); foreach my $c (keys %{Dancer::Cookies->cookies}) { my $cookie = Dancer::Cookies->cookies->{$c}; if (Dancer::Cookies->has_changed($cookie)) { - $response->header('Set-Cookie' => $cookie->to_header); + push(@c, $cookie->to_header); } } + $response->header('Set-Cookie' => \@c); return $response; } i have normal headers generation: wget -S http://172.20.124.111:3000/ --14:26:53-- http://172.20.124.111:3000/ => `index.html' Connecting to 172.20.124.111:3000... connected. HTTP request sent, awaiting response... HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: test=test; path=/; HttpOnly Set-Cookie: dancer.session=708630204583990864004761600357449618; path=/; HttpOnly Set-Cookie: test1=test1; path=/; HttpOnly X-Powered-By: Perl Dancer 1.3011 -- Close your eyes, look into the dream... Jabber ID : sapsan@gmail.com E-mail : sapsan@gmail.com
This is already fixed in devel ( https://github.com/sukria/Dancer/blob/devel/lib/Dancer/Renderer.pm#L60) Will be available in the next release. Thanks for the report! On Tue, Feb 22, 2011 at 1:39 PM, Alex Khrenov <sapsan@gmail.com> wrote:
When i try to set several cookies, i have trouble: only 1 cookie was set:
get '/' => sub { set_cookie('test' => 'test'); set_cookie('test1' => 'test1'); ... }
wget -S http://172.20.124.111:3000/ --14:22:48-- http://172.20.124.111:3000/ => `index.html' Connecting to 172.20.124.111:3000... connected. HTTP request sent, awaiting response... HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: test1=test1; path=/; HttpOnly X-Powered-By: Perl Dancer 1.3011
The problem, as i can see, is in the Renderer.pm, function response_with_headers.
With patch: --- Renderer.pm 2011-02-22 14:03:43.000000000 +0200 +++ Renderer.pm.new 2011-02-22 13:57:38.000000000 +0200 @@ -55,12 +55,14 @@ $response->header('X-Powered-By' => "Perl Dancer ${Dancer::VERSION}"); # add cookies + my @c = (); foreach my $c (keys %{Dancer::Cookies->cookies}) { my $cookie = Dancer::Cookies->cookies->{$c}; if (Dancer::Cookies->has_changed($cookie)) { - $response->header('Set-Cookie' => $cookie->to_header); + push(@c, $cookie->to_header); } } + $response->header('Set-Cookie' => \@c);
return $response; }
i have normal headers generation: wget -S http://172.20.124.111:3000/ --14:26:53-- http://172.20.124.111:3000/ => `index.html' Connecting to 172.20.124.111:3000... connected. HTTP request sent, awaiting response... HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Set-Cookie: test=test; path=/; HttpOnly Set-Cookie: dancer.session=708630204583990864004761600357449618; path=/; HttpOnly Set-Cookie: test1=test1; path=/; HttpOnly X-Powered-By: Perl Dancer 1.3011
-- Close your eyes, look into the dream...
Jabber ID : sapsan@gmail.com E-mail : sapsan@gmail.com _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- franck cuny http://lumberjaph.net - http://github.com/franckcuny
participants (2)
-
Alex Khrenov -
franck