Moved IE workarounds to be only in the HTTP engine
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index 6e46c81..3a73c04 100644 (file)
@@ -2,12 +2,13 @@ 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;
 use HTTP::Headers;
 use URI::QueryParam;
+use Scalar::Util ();
 
 # input position and length
 __PACKAGE__->mk_accessors(qw/read_position read_length/);
@@ -40,7 +41,8 @@ Finalize body.  Prints the response output.
 sub finalize_body {
     my ( $self, $c ) = @_;
     my $body = $c->response->body;
-    if ( ref $body && ( $body->can('read') || ref($body) eq 'GLOB' ) ) {
+    no warnings 'uninitialized';
+    if ( Scalar::Util::blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) {
         while ( !eof $body ) {
             read $body, my ($buffer), $CHUNKSIZE;
             last unless $self->write( $c, $buffer );
@@ -54,7 +56,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
 
@@ -67,13 +70,17 @@ sub finalize_cookies {
 
         my $val = $c->response->cookies->{$name};
 
-        my $cookie = CGI::Cookie->new(
-            -name    => $name,
-            -value   => $val->{value},
-            -expires => $val->{expires},
-            -domain  => $val->{domain},
-            -path    => $val->{path},
-            -secure  => $val->{secure} || 0
+        my $cookie = (
+            Scalar::Util::blessed($val)
+            ? $val
+            : CGI::Simple::Cookie->new(
+                -name    => $name,
+                -value   => $val->{value},
+                -expires => $val->{expires},
+                -domain  => $val->{domain},
+                -path    => $val->{path},
+                -secure  => $val->{secure} || 0
+            )
         );
 
         push @cookies, $cookie->as_string;
@@ -363,7 +370,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
 
@@ -371,7 +378,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) } );
     }
 }