X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FResponse.pm;h=ae6049d390ca857cf98a80ff1c5cd5f68058ac30;hb=9868e0a0023cc8b598d60f150ea367e0056a65f3;hp=fa15afbf354c42c813d4adc4fc7a57393ff4d729;hpb=9c056c82094f7550ac9e39408c52d248bcace7b3;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index fa15afb..ae6049d 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -3,11 +3,12 @@ package Catalyst::Response; use Moose; use HTTP::Headers; use Moose::Util::TypeConstraints; -use namespace::autoclean; use Scalar::Util 'blessed'; use Catalyst::Response::Writer; use Catalyst::Utils (); +use namespace::clean -except => ['meta']; + with 'MooseX::Emulate::Class::Accessor::Fast'; our $DEFAULT_ENCODE_CONTENT_TYPE_MATCH = qr{text|xml$|javascript$}; @@ -103,12 +104,24 @@ has _context => ( 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." ) + " 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 && @_ ); }; @@ -482,6 +495,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 @@ -538,7 +557,7 @@ finalized (there isn't one anyway) and you need to call the close method. 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) +=head2 $res->finalize_headers() Writes headers to response if not already written