X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=c4148963c5d2b739c1bc41a50fb39da3361c2f42;hb=cfdd890d1f76bd9403c5b8a30f902394297ffb68;hp=67993f199e8988c9f2c308bbf336ed4bb88ecb22;hpb=9560b708797123875e4743b5dac70c69fbc4a3ef;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 67993f1..c414896 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -10,38 +10,35 @@ use HTML::Entities; use HTTP::Body; use HTTP::Headers; use URI::QueryParam; -use Moose::Util::TypeConstraints; use Plack::Loader; -use Plack::Middleware::Conditional; -use Plack::Middleware::ReverseProxy; +use Catalyst::EngineLoader; +use Encode (); +use utf8; use namespace::clean -except => 'meta'; -has env => (is => 'ro', writer => '_set_env', clearer => '_clear_env'); - -# input position and length -has read_length => (is => 'rw'); -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', -); - -has _writer => ( - is => 'ro', - isa => duck_type([qw(write close)]), - writer => '_set_writer', - clearer => '_clear_writer', -); - # 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 @@ -78,9 +75,9 @@ sub finalize_body { $self->write( $c, $body ); } - $self->_writer->close; - $self->_clear_writer; - $self->_clear_env; + my $res = $c->response; + $res->_writer->close; + $res->_clear_writer; return; } @@ -115,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; } @@ -155,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 ) { @@ -171,7 +181,6 @@ sub finalize_error { $name = "