From: Christian Hansen Date: Sat, 16 Apr 2005 20:22:41 +0000 (+0000) Subject: Fixed Request/Response body X-Git-Tag: 5.7099_04~1497 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e060fe05e8770527de1f433b4ae4bc2cd1e8c303 Fixed Request/Response body --- diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index fb80e11..79ecbb8 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -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( <<"" ); $title diff --git a/lib/Catalyst/Engine/Apache.pm b/lib/Catalyst/Engine/Apache.pm index 7d11ea4..e66f434 100644 --- a/lib/Catalyst/Engine/Apache.pm +++ b/lib/Catalyst/Engine/Apache.pm @@ -42,7 +42,7 @@ This class overloads some methods from C. 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 diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 2840034..6d0fd12 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -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 diff --git a/lib/Catalyst/Engine/Test.pm b/lib/Catalyst/Engine/Test.pm index 88800fa..779a636 100644 --- a/lib/Catalyst/Engine/Test.pm +++ b/lib/Catalyst/Engine/Test.pm @@ -55,7 +55,7 @@ This class overloads some methods from C. 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 diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 04b7338..d6fb488 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -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 = \¶meters; 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 or C. + + 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 or C. - - print $c->request->input +Shortcut for $req->body. =item $req->match diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index a84e3c8..2d83a48 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -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 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)