X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=e6c5d6256f21a81548b07958a952e3c3bb25c31d;hb=4b0f97fc6eb94b7d347403cecbf9a71ec5322e37;hp=ca836f97c3a42340117933738b4e1f8890881a86;hpb=2e1d8aebc95c5800fe98b1dfb99f109c877cfe17;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ca836f9..e6c5d62 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -304,7 +304,8 @@ sub finalize_error { - # Trick IE + # Trick IE. Old versions of IE would display their own error page instead + # of ours if we'd give it less than 512 bytes. $c->res->{body} .= ( ' ' x 512 ); # Return 500 @@ -537,7 +538,7 @@ sub prepare_path { my $query = $env->{QUERY_STRING} ? '?' . $env->{QUERY_STRING} : ''; my $uri = $scheme . '://' . $host . '/' . $path . $query; - $ctx->request->uri( bless \$uri, $uri_class ); + $ctx->request->uri( (bless \$uri, $uri_class)->canonical ); # set the base URI # base must end in a slash @@ -743,19 +744,32 @@ header. The amount of input data that has already been read. -=head2 $self->run($c) +=head2 $self->run($app, $server) -Start the engine. Implemented by the various engine classes. +Start the engine. Builds a PSGI application and calls the +run method on the server passed in.. =cut sub run { my ($self, $app, @args) = @_; + my $server = pop @args if blessed $args[-1]; + $server ||= Plack::Loader->auto(); # We're not being called from a script, + # so auto detect what backend to run on. + # This does *NOT* cover mod_perl. # FIXME - Do something sensible with the options we're passed - $self->_run_psgi_app($self->_build_psgi_app($app, @args), @args); + my $psgi = $self->build_psgi_app($app, @args); + $server->run($psgi); } -sub _build_psgi_app { +=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. + +=cut + +sub build_psgi_app { my ($self, $app, @args) = @_; my $psgi_app = sub { @@ -781,12 +795,6 @@ sub _build_psgi_app { return $psgi_app; } -sub _run_psgi_app { - my ($self, $psgi_app, @args) = @_; - # FIXME - Need to be able to specify engine and pass options.. - Plack::Loader->auto(port => $args[0])->run($psgi_app); -} - =head2 $self->write($c, $buffer) Writes the buffer to the client.