X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=0f53b17d7f5776e11217be910511859f6cd8d6a4;hb=e3f6b891eadf91320fff9caf204ead09e54b51b0;hp=edef4174020663ddcb5d4d275c1b61758eb691ce;hpb=27dad9301094f25bcedc66c476ec8b9d61521fb7;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index edef417..0f53b17 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -20,6 +20,17 @@ use namespace::clean -except => 'meta'; 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'); has read_position => (is => 'rw'); @@ -31,11 +42,15 @@ has _response_cb => ( 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 => duck_type([qw(write close)]), + isa => 'Catalyst::Engine::Types::Writer', writer => '_set_writer', clearer => '_clear_writer', ); @@ -116,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; } @@ -331,6 +351,15 @@ Abstract method, allows engines to write headers to response sub finalize_headers { my ($self, $ctx) = @_; + # This is a less-than-pretty hack to avoid breaking the old + # Catalyst::Engine::PSGI. 5.9 Catalyst::Engine sets a response_cb and + # expects us to pass headers to it here, whereas Catalyst::Enngine::PSGI + # just pulls the headers out of $ctx->response in its run method and never + # sets response_cb. So take the lack of a response_cb as a sign that we + # don't need to set the headers. + + return unless $self->_has_response_cb; + my @headers; $ctx->response->headers->scan(sub { push @headers, @_ }); @@ -804,13 +833,13 @@ sub run { # instead the $app->handle method is called per request. $app->log->warn("Not supplied a Plack engine, falling back to engine auto-loader (are your scripts ancient?)") } + $app->run_options($options); $server->run($psgi, $options); } =head2 build_psgi_app ($app, @args) -Builds and returns a PSGI application closure, wrapping it in the reverse proxy -middleware if the using_frontend_proxy config setting is set. +Builds and returns a PSGI application closure. (Raw, not wrapped in middleware) =cut