clearer => '_clear_context',
);
-before [qw(status headers content_encoding content_length content_type header)] => sub {
+before [qw(status headers content_encoding content_length content_type )] => sub {
my $self = shift;
- $self->_context->log->warn(
+ $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 && @_ );
+ " Since we don't support tail headers this will not work as you might expect." )
+ if ( $self->_context && $self->finalized_headers && !$self->_has_response_cb && @_ );
+};
+
+# This has to be different since the first param to ->header is the header name and presumably
+# you should be able to request the header even after finalization, just not try to change it.
+before 'header' => sub {
+ my $self = shift;
+ my $header = shift;
+
+ $self->_context->log->warn(
+ "Useless setting a header value after finalize_headers and the response callback has been called." .
+ " Since we don't support tail headers this will not work as you might expect." )
+ if ( $self->_context && $self->finalized_headers && !$self->_has_response_cb && @_ );
};
sub output { shift->body(@_) }
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;
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<Catalyst::Response::Writer>, which is a lightweight