Do at least one (possibly empty) write when reading the response body from a filehandle.
Florian Ragwitz [Sun, 16 Aug 2009 09:19:58 +0000 (09:19 +0000)]
lib/Catalyst/Engine.pm

index b9ec98a..4271aae 100644 (file)
@@ -48,10 +48,12 @@ sub finalize_body {
     my $body = $c->response->body;
     no warnings 'uninitialized';
     if ( blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) {
-        while ( !eof $body ) {
+        my $got;
+        do {
             read $body, my ($buffer), $CHUNKSIZE;
             last unless $self->write( $c, $buffer );
-        }
+        } while $got > 0;
+
         close $body;
     }
     else {