From: Florian Ragwitz Date: Sun, 16 Aug 2009 09:19:58 +0000 (+0000) Subject: Do at least one (possibly empty) write when reading the response body from a filehandle. X-Git-Tag: 5.80008~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=be1c95030e15ef9d081808462688ec09f7daed99;hp=196f06d1c984b33021702e221afea7520cb8c596 Do at least one (possibly empty) write when reading the response body from a filehandle. --- diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index b9ec98a..4271aae 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -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 {