X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=8ceaef1779c5956bff8ac3e7141d56f012b772b7;hb=9f3ebd8a1961bb18c8d6c60cfbb807b9fb3ecd3b;hp=2ee2e01ecbb46338b601ca5d0a66bb55c5890e56;hpb=933ba40380c86f9642bcfbee446a04d48efe4544;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 2ee2e01..8ceaef1 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -42,7 +42,8 @@ sub finalize_headers { $c->response->header( Status => $c->response->status ); - print $c->response->headers->as_string("\015\012") . "\015\012"; + $self->{_header_buf} + = $c->response->headers->as_string("\015\012") . "\015\012"; } =head2 $self->prepare_connection($c) @@ -207,6 +208,23 @@ sub prepare_write { $self->NEXT::prepare_write($c); } +=head2 $self->write($c, $buffer) + +Writes the buffer to the client. + +=cut + +sub write { + my ( $self, $c, $buffer ) = @_; + + # Prepend the headers if they have not yet been sent + if ( my $headers = delete $self->{_header_buf} ) { + $buffer = $headers . $buffer; + } + + return $self->NEXT::write( $c, $buffer ); +} + =head2 $self->read_chunk($c, $buffer, $length) =cut