X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=21a1ec8b63f103f1d1594d01a582806d9bad2fc0;hb=bda80175df888e09ba36a36fd3651e1b01594486;hp=b6a11c66b373316af216e2bfb368608aa2b6968b;hpb=df93c9b5acab21be847ad74b86d812eca07b5b2f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index b6a11c6..21a1ec8 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'; @@ -1945,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(); @@ -3116,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, @@ -3442,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>,