X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=e3d705abc41853e005e25bac69affa063af2b0b2;hb=1a7ee7cd1d8a5296661aef16ea5726206d1709c1;hp=1cd7de6bbce22b05d0e59b8ef11767482ecd5d90;hpb=3157d22a51b6dd470bee2b7046b5878277bc64b5;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 1cd7de6..e3d705a 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -46,6 +46,7 @@ use Plack::Middleware::Head; use Plack::Middleware::HTTPExceptions; use Plack::Middleware::FixMissingBodyInRedirect; use Plack::Middleware::MethodOverride; +use Plack::Middleware::RemoveRedundantBody; use Plack::Util; use Class::Load 'load_class'; @@ -125,7 +126,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90059_004'; +our $VERSION = '5.90059_005'; sub import { my ( $class, @arguments ) = @_; @@ -1895,7 +1896,10 @@ sub finalize_cookies { my $c = shift; $c->engine->finalize_cookies( $c, @_ ) } =head2 $c->finalize_error -Finalizes error. +Finalizes error. If there is only one error in L and it is an object that +does C or C we rethrow the error and presume it caught by middleware +up the ladder. Otherwise we return the debugging error page (in debug mode) or we +return the default error page (production mode). =cut @@ -1942,14 +1946,6 @@ sub finalize_headers { # Remove incorrectly added body and content related meta data when returning # an information response, or a response the is required to not include a body - if ( $response->status =~ /^(1\d\d|[23]04)$/ ) { - if($response->has_body) { - $c->log->debug('Removing body for informational or no content http responses'); - $response->body(''); - $response->headers->remove_header("Content-Length"); - } - } - $c->finalize_cookies; $c->response->finalize_headers(); @@ -3113,6 +3109,7 @@ sub registered_middlewares { if(my $middleware = $class->_psgi_middleware) { return ( Plack::Middleware::HTTPExceptions->new, + Plack::Middleware::RemoveRedundantBody->new, Plack::Middleware::FixMissingBodyInRedirect->new, Plack::Middleware::ContentLength->new, Plack::Middleware::MethodOverride->new, @@ -3439,6 +3436,28 @@ C - See L. =back +=head1 EXCEPTIONS + +Generally when you throw an exception inside an Action (or somewhere in +your stack, such as in a model that an Action is calling) that exception +is caught by Catalyst and unless you either catch it yourself (via eval +or something like L or by reviewing the L stack, it +will eventually reach L and return either the debugging +error stack page, or the default error page. However, if your exception +can be caught by L, L will +instead rethrow it so that it can be handled by that middleware (which +is part of the default middleware). For example this would allow + + use HTTP::Throwable::Factory 'http_throw'; + + sub throws_exception :Local { + my ($self, $c) = @_; + + http_throw(SeeOther => { location => + $c->uri_for($self->action_for('redirect')) }); + + } + =head1 INTERNAL ACTIONS Catalyst uses internal actions like C<_DISPATCH>, C<_BEGIN>, C<_AUTO>, @@ -3942,7 +3961,7 @@ Upasana =head1 COPYRIGHT -Copyright (c) 2005, the above named PROJECT FOUNDER and CONTRIBUTORS. +Copyright (c) 2005-2014, the above named PROJECT FOUNDER and CONTRIBUTORS. =head1 LICENSE