X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=4e556626a77f2fc884ebed56c79b82aa29c5fb8a;hb=46aec47a553a7991d5a9e9faff176e9657777c44;hp=68c98758c1b85e5e7152688a9f4407e95033a422;hpb=9629478d55a9a9a891ff3e12557aa334a9783c58;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 68c9875..4e55662 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -41,6 +41,8 @@ use Plack::Middleware::ReverseProxy; use Plack::Middleware::IIS6ScriptNameFix; use Plack::Middleware::IIS7KeepAliveFix; use Plack::Middleware::LighttpdScriptNameFix; +use Plack::Middleware::ContentLength; +use Plack::Middleware::Head; use Plack::Util; use Class::Load 'load_class'; @@ -120,7 +122,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90059_001'; +our $VERSION = '5.90059_002'; sub import { my ( $class, @arguments ) = @_; @@ -1124,6 +1126,7 @@ sub setup { $class->setup_home( delete $flags->{home} ); + $class->setup_log( delete $flags->{log} ); $class->setup_plugins( delete $flags->{plugins} ); # Call plugins setup, this is stupid and evil. @@ -1134,7 +1137,6 @@ sub setup { $class->setup unless $Catalyst::__AM_RESTARTING; } - $class->setup_log( delete $flags->{log} ); $class->setup_middleware(); $class->setup_data_handlers(); $class->setup_dispatcher( delete $flags->{dispatcher} ); @@ -1857,11 +1859,6 @@ sub finalize { $c->finalize_headers unless $c->response->finalized_headers; - # HEAD request - if ( $c->request->method eq 'HEAD' ) { - $c->response->body(''); - } - $c->finalize_body; } @@ -1938,26 +1935,6 @@ EOF } } - # Content-Length - if ( defined $response->body && length $response->body && !$response->content_length ) { - - # get the length from a filehandle - if ( blessed( $response->body ) && $response->body->can('read') || ref( $response->body ) eq 'GLOB' ) - { - my $size = -s $response->body; - if ( $size ) { - $response->content_length( $size ); - } - else { - $c->log->warn('Serving filehandle without a content-length'); - } - } - else { - # everything should be bytes at this point, but just in case - $response->content_length( length( $response->body ) ); - } - } - # 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 @@ -3127,7 +3104,10 @@ L (which is now considered deprecated) sub registered_middlewares { my $class = shift; if(my $middleware = $class->_psgi_middleware) { - return @$middleware; + return ( + Plack::Middleware::ContentLength->new, + Plack::Middleware::Head->new, + @$middleware); } else { die "You cannot call ->registered_middlewares until middleware has been setup"; }