X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FResponse.pm;h=e87ba61dbf8ce88392df19ab2417406b05bbcde0;hp=74d59fe87b7e719469646624c8a1ff151c347f45;hb=ed5a562b5c77df8d42b562af5733641baa73107d;hpb=67fd25bc03bc87a19db237a13fcb1cd157252101 diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index 74d59fe..e87ba61 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -109,7 +109,7 @@ before [qw(status headers content_encoding content_length content_type header)] $self->_context->log->warn( "Useless setting a header value after finalize_headers and the response callback has been called." . " Not what you want." ) - if ( $self->finalized_headers && !$self->_has_response_cb && @_ ); + if ( $self->_context && $self->finalized_headers && !$self->_has_response_cb && @_ ); }; sub output { shift->body(@_) } @@ -134,6 +134,20 @@ sub write { return $len; } +sub unencoded_write { + my ( $self, $buffer ) = @_; + + # Finalize headers if someone manually writes output + $self->_context->finalize_headers unless $self->finalized_headers; + + $buffer = q[] unless defined $buffer; + + my $len = length($buffer); + $self->_writer->write($buffer); + + return $len; +} + sub finalize_headers { my ($self) = @_; return; @@ -468,6 +482,12 @@ http 1.1 webservers support this). If there is an encoding set, we encode each line of the response (the default encoding is UTF-8). +=head2 $res->unencoded_write( $data ) + +Works just like ->write but we don't apply any content encoding to C<$data>. Use +this if you are already encoding the $data or the data is arriving from an encoded +storage. + =head2 $res->write_fh Returns an instance of L, which is a lightweight