Fixed Request/Response body
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / CGI.pm
index 84fadd9..6d0fd12 100644 (file)
@@ -57,6 +57,17 @@ This class overloads some methods from C<Catalyst::Engine>.
 
 =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
@@ -119,18 +133,18 @@ sub prepare_parameters {
     
     my ( @params );
 
-    for my $param ( $c->cgi->param ) { 
-        for my $value (  $c->cgi->param($param) ) {
+    for my $param ( $c->cgi->url_param ) { 
+        for my $value (  $c->cgi->url_param($param) ) {
             push ( @params, $param, $value );
         }
     }
-    
-    for my $param ( $c->cgi->url_param ) { 
-        for my $value (  $c->cgi->url_param($param) ) {
+
+    for my $param ( $c->cgi->param ) { 
+        for my $value (  $c->cgi->param($param) ) {
             push ( @params, $param, $value );
         }
     }
-    
     $c->req->_assign_values( $c->req->parameters, \@params );
 }