From: John Napiorkowski Date: Sat, 21 Dec 2013 19:45:53 +0000 (-0600) Subject: remove custom catalyst code and use Plack Middleware instead X-Git-Tag: 5.90060~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=aa20e9f5cfc9b4addb7d8a76024ee66b492ef1fa remove custom catalyst code and use Plack Middleware instead --- diff --git a/Changes b/Changes index 036300d..05a4cec 100644 --- a/Changes +++ b/Changes @@ -12,7 +12,16 @@ properly non blocking streaming when running under a supporting server like Twiggy. See Catalyst::Delta for more. This change might cause issues if you are making heaving use of streaming (although in general we expect things - to work much better. + to work much better. + - In the case when we remove a content body from the response because you set + an information status or a no content type status, warn that we are doing so + when in debug mode. You might see additional debugging information to help + you find and remove unneeded response bodies. + - Updated the code where Catalyst tries to guess a content length when you + fail to provide one. This should cause less issues when trying to guess the + length of a funky filehandle. This now uses Plack::Middleware::ContentLength + - Removed custom code to remove body content when the request is HEAD and + swapped it for Plack::Middleware::Head. 5.90059_001 - 2013-12-19 - Removed deprecated Regexp dispatch type from dependency list. If you are diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 68c9875..bed3da7 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'; @@ -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"; } diff --git a/lib/Catalyst/Delta.pod b/lib/Catalyst/Delta.pod index 8281a0d..3e76cf3 100755 --- a/lib/Catalyst/Delta.pod +++ b/lib/Catalyst/Delta.pod @@ -40,6 +40,9 @@ where a supporting server will start chunking output. If this is an issue you can apply the middleware L or report specific problems to the dev team. +Also, we have started migrating code in Catalyst to equivilent Plack +Middleware when such exists and is correct to do so. + =head2 VERSION 5.9XXXX 'cataplack' The Catalyst::Engine sub-classes have all been removed and deprecated,