X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;fp=lib%2FCatalyst%2FEngine.pm;h=b8d29a4609b4073d87c77de620825f7ddb832819;hp=3b7c7fa83197b7471ca781e2da70b2a43bd61009;hb=e37f92f5a9e3e83019ae0c2895439121bf533cde;hpb=717fc5c90d2cbbd6288bae9be82dbd8f6b917bab diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 3b7c7fa..b8d29a4 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -57,24 +57,17 @@ See L. Finalize body. Prints the response output as blocking stream if it looks like a filehandle, otherwise write it out all in one go. If there is no body in the response, we assume you are handling it 'manually', such as for nonblocking -style or asynchronous streaming responses. - -By default we do not close the writer object in case we are in an event loop -and there is deferred activity. However if you have some sloppy code that is -closing over an unweakened context ($c) this could lead to the writer NEVER -being closed. In versions of Catalyst 5.90030 and older, we used to forcibly -close the writer in this method, but we no longer do that since it prevented us -from introducing proper asynchronous support in Catalyst core. If you have old -code that is leaking context but was otherwise working and you don't want to fix -your memory leaks (is really the best idea) you can force enable the old -behavior (and lose asynchronous support) by setting the global configuration key -C to true. See L -for more if you have this issue. +style or asynchronous streaming responses. You do this by calling L<\write> +several times (which sends HTTP headers if needed) or you close over L<\write_fh>. + +See L and L for more. =cut sub finalize_body { my ( $self, $c ) = @_; + return if $c->response->has_write_fh; + my $body = $c->response->body; no warnings 'uninitialized'; if ( blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) { @@ -90,11 +83,9 @@ sub finalize_body { $self->write( $c, $body ); } - if($c->config->{aggressively_close_writer_on_finalize_body}) { - my $res = $c->response; - $res->_writer->close; - $res->_clear_writer; - } + my $res = $c->response; + $res->_writer->close; + $res->_clear_writer; return; }