X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=1e56bdc89afe2d9145a6a655ccf93b4a7b999b30;hb=676bed72afa0c79b9f26e1d548a49dbfb6ea15c7;hp=41c4b773d8ca5d1586e9b4660ce7821019e2de16;hpb=d2278086877372c00bcefc607a4713d0fded4d53;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 41c4b77..1e56bdc 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -10,10 +10,26 @@ use HTML::Entities; use HTTP::Body; use HTTP::Headers; use URI::QueryParam; +use Moose::Util::TypeConstraints; +use Plack::Loader; +use Catalyst::EngineLoader; +use Encode (); +use utf8; use namespace::clean -except => 'meta'; -has env => (is => 'rw'); +has env => (is => 'ro', writer => '_set_env', clearer => '_clear_env'); + +my $WARN_ABOUT_ENV = 0; +around env => sub { + my ($orig, $self, @args) = @_; + if(@args) { + warn "env as a writer is deprecated, you probably need to upgrade Catalyst::Engine::PSGI" + unless $WARN_ABOUT_ENV++; + return $self->_set_env(@args); + } + return $self->$orig; +}; # input position and length has read_length => (is => 'rw'); @@ -21,6 +37,24 @@ has read_position => (is => 'rw'); has _prepared_write => (is => 'rw'); +has _response_cb => ( + is => 'ro', + isa => 'CodeRef', + writer => '_set_response_cb', + clearer => '_clear_response_cb', + predicate => '_has_response_cb', +); + +subtype 'Catalyst::Engine::Types::Writer', + as duck_type([qw(write close)]); + +has _writer => ( + is => 'ro', + isa => 'Catalyst::Engine::Types::Writer', + writer => '_set_writer', + clearer => '_clear_writer', +); + # Amount of data to read from input on each pass our $CHUNKSIZE = 64 * 1024; @@ -59,6 +93,12 @@ sub finalize_body { else { $self->write( $c, $body ); } + + $self->_writer->close; + $self->_clear_writer; + $self->_clear_env; + + return; } =head2 $self->finalize_cookies($c) @@ -91,6 +131,11 @@ sub finalize_cookies { -httponly => $val->{httponly} || 0, ) ); + if (!defined $cookie) { + $c->log->warn("undef passed in '$name' cookie value - not setting cookie") + if $c->debug; + next; + } push @cookies, $cookie->as_string; } @@ -131,6 +176,14 @@ sub finalize_error { $c->res->content_type('text/html; charset=utf-8'); my $name = ref($c)->config->{name} || join(' ', split('::', ref $c)); + + # Prevent Catalyst::Plugin::Unicode::Encoding from running. + # This is a little nasty, but it's the best way to be clean whether or + # not the user has an encoding plugin. + + if ($c->can('encoding')) { + $c->{encoding} = ''; + } my ( $title, $error, $infos ); if ( $c->debug ) { @@ -166,7 +219,6 @@ sub finalize_error { $error = ''; $infos = <<"";
-(es) Por favor inténtelo de nuevo más tarde (en) Please come back later (fr) SVP veuillez revenir plus tard (de) Bitte versuchen sie es spaeter nocheinmal @@ -280,11 +332,12 @@ sub finalize_error {