Swapped out CGI::Cookie for CGI::Simple::Cookie, dumped Test::MockObject from the...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index de506cb..7f7a661 100644 (file)
@@ -2,7 +2,7 @@ package Catalyst::Engine;
 
 use strict;
 use base 'Class::Accessor::Fast';
-use CGI::Cookie;
+use CGI::Simple::Cookie;
 use Data::Dump qw/dump/;
 use HTML::Entities;
 use HTTP::Body;
@@ -54,7 +54,8 @@ sub finalize_body {
 
 =head2 $self->finalize_cookies($c)
 
-Create CGI::Cookies from $c->res->cookies, and set them as response headers.
+Create CGI::Simple::Cookie objects from $c->res->cookies, and set them as
+response headers.
 
 =cut
 
@@ -62,15 +63,18 @@ sub finalize_cookies {
     my ( $self, $c ) = @_;
 
     my @cookies;
-    while ( my ( $name, $cookie ) = each %{ $c->response->cookies } ) {
 
-        my $cookie = CGI::Cookie->new(
+    foreach my $name ( keys %{ $c->response->cookies } ) {
+
+        my $val = $c->response->cookies->{$name};
+
+        my $cookie = CGI::Simple::Cookie->new(
             -name    => $name,
-            -value   => $cookie->{value},
-            -expires => $cookie->{expires},
-            -domain  => $cookie->{domain},
-            -path    => $cookie->{path},
-            -secure  => $cookie->{secure} || 0
+            -value   => $val->{value},
+            -expires => $val->{expires},
+            -domain  => $val->{domain},
+            -path    => $val->{path},
+            -secure  => $val->{secure} || 0
         );
 
         push @cookies, $cookie->as_string;
@@ -360,7 +364,7 @@ sub prepare_connection { }
 
 =head2 $self->prepare_cookies($c)
 
-Parse cookies from header. Sets a L<CGI::Cookie> object.
+Parse cookies from header. Sets a L<CGI::Simple::Cookie> object.
 
 =cut
 
@@ -368,7 +372,7 @@ sub prepare_cookies {
     my ( $self, $c ) = @_;
 
     if ( my $header = $c->request->header('Cookie') ) {
-        $c->req->cookies( { CGI::Cookie->parse($header) } );
+        $c->req->cookies( { CGI::Simple::Cookie->parse($header) } );
     }
 }
 
@@ -388,13 +392,15 @@ sub prepare_parameters {
     my ( $self, $c ) = @_;
 
     # We copy, no references
-    while ( my ( $name, $param ) = each %{ $c->request->query_parameters } ) {
+    foreach my $name ( keys %{ $c->request->query_parameters } ) {
+        my $param = $c->request->query_parameters->{$name};
         $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param;
         $c->request->parameters->{$name} = $param;
     }
 
     # Merge query and body parameters
-    while ( my ( $name, $param ) = each %{ $c->request->body_parameters } ) {
+    foreach my $name ( keys %{ $c->request->body_parameters } ) {
+        my $param = $c->request->body_parameters->{$name};
         $param = ref $param eq 'ARRAY' ? [ @{$param} ] : $param;
         if ( my $old_param = $c->request->parameters->{$name} ) {
             if ( ref $old_param eq 'ARRAY' ) {