X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=8950d73dd04dfa0f790337b70dfd92c26267a02c;hb=a739692c785a7a0ac8164034c1e0b7e93d7ac71a;hp=84fadd9124b3060615786c90fdf70ff0e58ef7d9;hpb=5b387dfc825bb5a5a78672693497f5d7e792e9d4;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 84fadd9..8950d73 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -57,6 +57,17 @@ This class overloads some methods from C. =over 4 +=item $c->finalize_body + +Prints the response output to STDOUT. + +=cut + +sub finalize_body { + my $c = shift; + print $c->response->output; +} + =item $c->finalize_headers =cut @@ -70,15 +81,18 @@ sub finalize_headers { print "\015\012"; } -=item $c->finalize_output - -Prints the response output to STDOUT. +=item $c->prepare_body =cut -sub finalize_output { +sub prepare_body { my $c = shift; - print $c->response->output; + + # XXX this is undocumented in CGI.pm. If Content-Type is not + # application/x-www-form-urlencoded or multipart/form-data + # CGI.pm will read STDIN into a param, POSTDATA. + + $c->request->body( $c->cgi->param('POSTDATA') ); } =item $c->prepare_connection @@ -118,20 +132,22 @@ sub prepare_parameters { my $c = shift; my ( @params ); + + if ( $c->request->method eq 'POST' ) { + for my $param ( $c->cgi->url_param ) { + for my $value ( $c->cgi->url_param($param) ) { + push ( @params, $param, $value ); + } + } + } for my $param ( $c->cgi->param ) { for my $value ( $c->cgi->param($param) ) { push ( @params, $param, $value ); } } - - for my $param ( $c->cgi->url_param ) { - for my $value ( $c->cgi->url_param($param) ) { - push ( @params, $param, $value ); - } - } - - $c->req->_assign_values( $c->req->parameters, \@params ); + + $c->request->param(\@params); } =item $c->prepare_path @@ -170,8 +186,8 @@ sub prepare_path { =cut sub prepare_request { - my $c = shift; - $c->cgi( CGI->new ); + my ( $c, $cgi ) = @_; + $c->cgi( $cgi || CGI->new ); $c->cgi->_reset_globals; } @@ -211,7 +227,7 @@ sub prepare_uploads { } } - $c->req->_assign_values( $c->req->uploads, \@uploads ); + $c->request->upload(\@uploads); } =item $c->run