From: Sebastian Riedel Date: Thu, 20 Oct 2005 15:46:16 +0000 (+0000) Subject: Added support for IO::Handle in $c->res->body X-Git-Tag: 5.7099_04~1173 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=f4a57de40a851a87a5c9513fd8cb55dbd6cec12c;hp=b52dc42d2f5b404fa7735196b4c12c598e5de39e Added support for IO::Handle in $c->res->body --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index e9fed2e..c904ed3 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1626,6 +1626,8 @@ Andy Wardley Andreas Marienborg +Andrew Bramble + Andrew Ford Andrew Ruthven diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index b5cba7b..7b8fe91 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -44,8 +44,16 @@ Finalize body. Prints the response output. sub finalize_body { my ( $self, $c ) = @_; - - $self->write( $c, $c->response->output ); + if ( ref $c->response->body && $c->response->body->can('read') ) { + my $buffer; + while ( !$c->response->body->eof() ) { + $c->response->body->read( $buffer, $CHUNKSIZE ); + $self->write( $c, $buffer ); + } + } + else { + $self->write( $c, $c->response->output ); + } } =item $self->finalize_cookies($c) @@ -341,10 +349,10 @@ sub prepare_query_parameters { $query_string =~ s/;/&/g; my $u = URI->new( '', 'http' ); - $u->query( $query_string ); - for my $key ( $u->query_param ) { - my @vals = $u->query_param($key); - $c->request->query_parameters->{$key} = @vals > 1 ? [@vals] : $vals[0]; + $u->query($query_string); + for my $key ( $u->query_param ) { + my @vals = $u->query_param($key); + $c->request->query_parameters->{$key} = @vals > 1 ? [@vals] : $vals[0]; } } @@ -386,11 +394,11 @@ sub prepare_uploads { push @uploads, $u; } $c->request->uploads->{$name} = @uploads > 1 ? \@uploads : $uploads[0]; - + # support access to the filename as a normal param my @filenames = map { $_->{filename} } @uploads; - $c->request->parameters->{$name} - = @filenames > 1 ? \@filenames : $filenames[0]; + $c->request->parameters->{$name} = + @filenames > 1 ? \@filenames : $filenames[0]; } }