Renaming all the attributes, as making them _private breaks multiple plugins. See...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index c0cdf1e..b751ba3 100644 (file)
@@ -16,6 +16,8 @@ use Scalar::Util ();
 has read_length => (is => 'rw');
 has read_position => (is => 'rw');
 
+has _prepared_write => (is => 'rw');
+
 no Moose;
 
 # Amount of data to read from input on each pass
@@ -96,7 +98,7 @@ sub finalize_cookies {
 
 =head2 $self->finalize_error($c)
 
-Output an apropriate error message, called if there's an error in $c
+Output an appropriate error message. Called if there's an error in $c
 after the dispatch has finished. Will output debug messages if Catalyst
 is in debug mode, or a `please come back later` message otherwise.
 
@@ -123,8 +125,8 @@ sub finalize_error {
         $name  = "<h1>$name</h1>";
 
         # Don't show context in the dump
-        delete $c->req->{_context};
-        delete $c->res->{_context};
+        $c->req->_clear_context;
+        $c->res->_clear_context;
 
         # Don't show body parser in the dump
         delete $c->req->{_body};
@@ -618,11 +620,13 @@ Writes the buffer to the client.
 sub write {
     my ( $self, $c, $buffer ) = @_;
 
-    unless ( $self->{_prepared_write} ) {
+    unless ( $self->_prepared_write ) {
         $self->prepare_write($c);
-        $self->{_prepared_write} = 1;
+        $self->_prepared_write(1);
     }
     
+    return 0 if !defined $buffer;
+    
     my $len   = length($buffer);
     my $wrote = syswrite STDOUT, $buffer;