X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=095c4ffe567372b332dc4618748101006d9fc5f6;hp=ecd6834a08eab7b35e24cdedd3ec93e0cc7caa74;hb=74dafab798a163c251e09de7fcc21a267d1678a6;hpb=c4bed79ab77673a4b6be73d2e45a27befe91ea3a diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ecd6834..095c4ff 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') ) { + while ( !$c->response->body->eof() ) { + $c->response->body->read( my $buffer, $CHUNKSIZE ); + $self->write( $c, $buffer ); + } + $c->response->body->close(); + } + else { + $self->write( $c, $c->response->body ); + } } =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,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]; } }