use Plack::Middleware::HTTPExceptions;
use Plack::Middleware::FixMissingBodyInRedirect;
use Plack::Middleware::MethodOverride;
+use Plack::Middleware::RemoveRedundantBody;
use Plack::Util;
use Class::Load 'load_class';
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90059_004';
+our $VERSION = '5.90059_006';
sub import {
my ( $class, @arguments ) = @_;
# Should be the last thing we do so that user things hooking
# setup_finalize can log..
$class->log->_flush() if $class->log->can('_flush');
- return 1; # Explicit return true as people have __PACKAGE__->setup as the last thing in their class. HATE.
+ return $class || 1; # Just in case someone named their Application 0...
}
=head2 $app->setup_finalize
# 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();
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,
=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<Try::Tiny> or by reviewing the L</error> stack, it
+will eventually reach L</finalize_errors> and return either the debugging
+error stack page, or the default error page. However, if your exception
+can be caught by L<Plack::Middleware::HTTPExceptions>, L<Catalyst> 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>,
=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