Fixed config in C::Base and stash in C::Engine
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index cbc5896..d6673a2 100644 (file)
@@ -179,12 +179,13 @@ sub finalize {
         $c->finalize_error;
     }
 
-    if ( !$c->response->body_length && $c->response->status !~ /^(1|3)\d\d$/ ) {
+    if ( !$c->response->body && $c->response->status !~ /^(1|3)\d\d$/ ) {
         $c->finalize_error;
     }
 
-    if ( $c->response->body_length && !$c->response->content_length ) {
-        $c->response->content_length( $c->response->body_length );
+    if ( $c->response->body && !$c->response->content_length ) {
+        use bytes;    # play safe with a utf8 aware perl
+        $c->response->content_length( length $c->response->body );
     }
 
     my $status = $c->finalize_headers;
@@ -400,20 +401,20 @@ sub prepare {
         request => Catalyst::Request->new(
             {
                 arguments  => [],
-                body       => undef,
                 cookies    => {},
                 headers    => HTTP::Headers->new,
                 parameters => {},
+                secure     => 0,
                 snippets   => [],
                 uploads    => {}
             }
         ),
         response => Catalyst::Response->new(
-            { 
-                body       => undef,
-                cookies    => {},
-                headers    => HTTP::Headers->new,
-                status     => 200
+            {
+                body    => '',
+                cookies => {},
+                headers => HTTP::Headers->new,
+                status  => 200
             }
         ),
         stash => {},
@@ -697,8 +698,8 @@ Returns a hashref containing all your data.
 
 sub stash {
     my $self = shift;
-    if ( $_[0] ) {
-        my $stash = $_[1] ? {@_} : $_[0];
+    if ( @_ ) {
+        my $stash = @_ > 1 ? {@_} : $_[0];
         while ( my ( $key, $val ) = each %$stash ) {
             $self->{stash}->{$key} = $val;
         }