X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=7b8fe9109b89948e2a118346fbca4b3a60cf208b;hb=f4a57de40a851a87a5c9513fd8cb55dbd6cec12c;hp=ba408f9b56cc517f862b6968400353bc73df59ce;hpb=4f5ebacdba8bc446f80d0e8999d117d80f9d2c98;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ba408f9..7b8fe91 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -7,6 +7,7 @@ use Data::Dumper; use HTML::Entities; use HTTP::Body; use HTTP::Headers; +use URI::QueryParam; # input position and length __PACKAGE__->mk_accessors(qw/read_position read_length/); @@ -43,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) @@ -333,7 +342,19 @@ sub prepare_path { } =cut -sub prepare_query_parameters { } +sub prepare_query_parameters { + my ( $self, $c, $query_string ) = @_; + + # replace semi-colons + $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]; + } +} =item $self->prepare_read($c) @@ -373,6 +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]; } }