Fixed Request/Response body
Christian Hansen [Sat, 16 Apr 2005 20:22:41 +0000 (20:22 +0000)]
lib/Catalyst/Engine.pm
lib/Catalyst/Engine/Apache.pm
lib/Catalyst/Engine/CGI.pm
lib/Catalyst/Engine/Test.pm
lib/Catalyst/Request.pm
lib/Catalyst/Response.pm

index fb80e11..79ecbb8 100644 (file)
@@ -179,13 +179,13 @@ sub finalize {
         $c->finalize_error;
     }
 
-    if ( !$c->response->output && $c->response->status !~ /^(1|3)\d\d$/ ) {
+    if ( !$c->response->body && $c->response->status !~ /^(1|3)\d\d$/ ) {
         $c->finalize_error;
     }
 
-    if ( $c->response->output && !$c->response->content_length ) {
+    if ( $c->response->body && !$c->response->content_length ) {
         use bytes;    # play safe with a utf8 aware perl
-        $c->response->content_length( length $c->response->output );
+        $c->response->content_length( length $c->response->body );
     }
 
     my $status = $c->finalize_headers;
@@ -271,7 +271,7 @@ sub finalize_error {
 
         $name = '';
     }
-    $c->res->output( <<"" );
+    $c->res->body( <<"" );
 <html>
 <head>
     <title>$title</title>
index 7d11ea4..e66f434 100644 (file)
@@ -42,7 +42,7 @@ This class overloads some methods from C<Catalyst::Engine>.
 
 sub finalize_body {
     my $c = shift;
-    $c->apache->print( $c->response->output );
+    $c->apache->print( $c->response->body );
 }
 
 =item $c->prepare_body
@@ -63,7 +63,7 @@ sub prepare_body {
         $content .= $buffer;
     }
     
-    $c->request->input($content);
+    $c->request->body($content);
 }
 
 =item $c->prepare_connection
index 2840034..6d0fd12 100644 (file)
@@ -92,7 +92,7 @@ sub prepare_body {
     # application/x-www-form-urlencoded or multipart/form-data
     # CGI.pm will read STDIN into a param, POSTDATA.
 
-    $c->request->input( $c->cgi->param('POSTDATA') );
+    $c->request->body( $c->cgi->param('POSTDATA') );
 }
 
 =item $c->prepare_connection
index 88800fa..779a636 100644 (file)
@@ -55,7 +55,7 @@ This class overloads some methods from C<Catalyst::Engine>.
 
 sub finalize_body {
     my $c = shift;
-    $c->http->response->content( $c->response->output );
+    $c->http->response->content( $c->response->body );
 }
 
 =item $c->finalize_headers
@@ -78,7 +78,7 @@ sub finalize_headers {
 
 sub prepare_body {
     my $c = shift;
-    $c->request->input( $c->http->request->content );
+    $c->request->body( $c->http->request->content );
 }
 
 =item $c->prepare_connection
index 04b7338..d6fb488 100644 (file)
@@ -4,11 +4,12 @@ use strict;
 use base 'Class::Accessor::Fast';
 
 __PACKAGE__->mk_accessors(
-    qw/action address arguments base cookies headers input hostname match 
+    qw/action address arguments body base cookies headers hostname match
       method parameters path snippets uploads/
 );
 
 *args   = \&arguments;
+*input  = \&body;
 *params = \&parameters;
 
 sub content_encoding { shift->headers->content_encoding(@_) }
@@ -110,7 +111,10 @@ Contains the url base. This will always have a trailing slash.
 
 =item $req->body
 
-Shortcut for $req->input.
+Contains the message body of the request unless Content-Type is
+C<application/x-www-form-urlencoded> or C<multipart/form-data>.
+
+    print $c->request->body
 
 =item $req->content_encoding
 
@@ -148,10 +152,7 @@ Contains the hostname of the remote user.
 
 =item $req->input
 
-Contains the message body of the request unless Content-Type is
-C<application/x-www-form-urlencoded> or C<multipart/form-data>.
-
-    print $c->request->input
+Shortcut for $req->body.
 
 =item $req->match
 
index a84e3c8..2d83a48 100644 (file)
@@ -3,7 +3,9 @@ package Catalyst::Response;
 use strict;
 use base 'Class::Accessor::Fast';
 
-__PACKAGE__->mk_accessors(qw/cookies headers output redirect status/);
+__PACKAGE__->mk_accessors(qw/cookies body headers redirect status/);
+
+*output = \&body;
 
 sub content_encoding { shift->headers->content_encoding(@_) }
 sub content_length   { shift->headers->content_length(@_)   }
@@ -39,9 +41,11 @@ to response data.
 
 =over 4
 
-=item $resp->body
+=item $resp->body($text)
+
+    $c->response->body('Catalyst rocks!');
 
-Shortcut for $resp->output.
+Contains the final output.
 
 =item $resp->content_encoding
 
@@ -71,11 +75,9 @@ Returns a L<HTTP::Headers> object containing the headers.
 
     $c->response->headers->header( 'X-Catalyst' => $Catalyst::VERSION );
 
-=item $resp->output($text)
-
-Contains the final output.
+=item $resp->output
 
-    $c->response->output('Catalyst rocks!');
+Shortcut to $resp->body
 
 =item $resp->redirect($url)