Close ->res->body if it's a handle
Andy Grundman [Thu, 20 Oct 2005 16:29:37 +0000 (16:29 +0000)]
Changes
lib/Catalyst/Engine.pm

diff --git a/Changes b/Changes
index fb09dd6..81d3220 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
 Tis file documents the revision history for Perl extension Catalyst.
 
 5.50
+        - Added support for passing an IO::Handle object to $c->res->body.
+          (Andrew Bramble)
         - Added a new welcome screen.
         - Included Catalyst buttons and icons in helper.
         - Added Static::Simple plugin to core.
index 7b8fe91..095c4ff 100644 (file)
@@ -45,14 +45,14 @@ Finalize body.  Prints the response output.
 sub finalize_body {
     my ( $self, $c ) = @_;
     if ( ref $c->response->body && $c->response->body->can('read') ) {
-        my $buffer;
         while ( !$c->response->body->eof() ) {
-            $c->response->body->read( $buffer, $CHUNKSIZE );
+            $c->response->body->read( my $buffer, $CHUNKSIZE );
             $self->write( $c, $buffer );
         }
+        $c->response->body->close();
     }
     else {
-        $self->write( $c, $c->response->output );
+        $self->write( $c, $c->response->body );
     }
 }