X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FResponse.pm;h=6dc661e534ff6e77c5fca073fdea20ce6d057bc1;hb=e5cd6cc061d87d09a29fe67c7c3ab8fc386a5af0;hp=68ab474b94794fb1c3f2cefbdfeb258260f45c6d;hpb=684ca75d81f91dc5302f1654d7029c93be4f5a37;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index 68ab474..6dc661e 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -43,22 +43,21 @@ has headers => ( required => 1, lazy => 1, ); +has _context => ( + is => 'rw', + weak_ref => 1, + clearer => '_clear_context', +); sub output { shift->body(@_) } sub code { shift->status(@_) } -=head2 $self->write($buffer) - -Writes the buffer to the client. - -=cut - sub write { my ( $self, $buffer ) = @_; # Finalize headers if someone manually writes output - $self->finalize_headers; + $self->_context->finalize_headers unless $self->finalized_headers; $buffer = q[] unless defined $buffer; @@ -68,12 +67,6 @@ sub write { return $len; } -=head2 $self->finalize_headers($c) - -Abstract method, allows engines to write headers to response - -=cut - sub finalize_headers { my ($self) = @_; @@ -258,6 +251,10 @@ Writes $data to the output stream. Prints @data to the output stream, separated by $,. This lets you pass the response object to functions that want to write to an L. +=head2 $self->finalize_headers($c) + +Writes headers to response if not already written + =head2 DEMOLISH Ensures that the response is flushed and closed at the end of the