X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=2367139764d3430572bbc79c727bc2091566ba0e;hb=1cc1daddba7f95b39511329606761cd2ba7c4ed6;hp=41c4b773d8ca5d1586e9b4660ce7821019e2de16;hpb=d2278086877372c00bcefc607a4713d0fded4d53;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 41c4b77..2367139 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -10,20 +10,35 @@ use HTML::Entities; use HTTP::Body; use HTTP::Headers; use URI::QueryParam; +use Plack::Loader; +use Catalyst::EngineLoader; +use Encode (); +use utf8; use namespace::clean -except => 'meta'; -has env => (is => 'rw'); - -# input position and length -has read_length => (is => 'rw'); -has read_position => (is => 'rw'); - -has _prepared_write => (is => 'rw'); - # Amount of data to read from input on each pass our $CHUNKSIZE = 64 * 1024; +# XXX - this is only here for compat, do not use! +has env => ( is => 'rw', writer => '_set_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; +}; + +# XXX - Only here for Engine::PSGI compat +sub prepare_connection { + my ($self, $ctx) = @_; + $ctx->request->prepare_connection; +} + =head1 NAME Catalyst::Engine - The Catalyst Engine @@ -59,6 +74,12 @@ sub finalize_body { else { $self->write( $c, $body ); } + + my $res = $c->response; + $res->_writer->close; + $res->_clear_writer; + + return; } =head2 $self->finalize_cookies($c) @@ -91,6 +112,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 +157,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 ) { @@ -147,7 +181,6 @@ sub finalize_error { $name = "
-(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,28 +312,28 @@ sub finalize_error {