[Catalyst] Incorrect $c->req->base using Catalyst::Engine::SCGI on Win32

Will Hawes wdhawes at gmail.com
Wed Jun 24 15:44:01 GMT 2009


I've noticed that $c->req->base is set incorrectly on Win32 using the
newly released Catalyst::Engine::SCGI.

Steps to reproduce:

catalyst.pl MyApp
cd MyApp
perl script\myapp_create.pl SCGI
perl script\myapp_scgi.pl

Start Apache with the following configuration:

LoadModule scgi_module modules/mod_scgi.so
<VirtualHost *>
    SCGIMount / 127.0.0.1:9000
</VirtualHost>

Add the following methods to MyApp::Controller::Root:

sub action :Global {
    my( $self, $c ) = @_;
    die $c->uri_for( $c->action );
}

sub Catalyst::Engine::SCGI::prepare_path {
    my( $self, $c ) = @_;
    my $env = $self->env;
    use Data::Dumper;
    warn Dumper $env;
    return $self->next::method( $c );
}

Visit http://localhost/action in a browser.

>From a combination of the debug screen in the browser and the server
output, I can see the following under Apache 2.0 on Win32 (observed on
2 machines):

PATH_INFO - /action
SCRIPT_NAME - /action
$c->req->base - http://localhost/action/
$c->uri_for( $c->action ) - http://localhost/action/action

I don't think the SCRIPT_NAME header should contain anything. Under
Apache 2.2 on Ubuntu 9.04, I see the behaviour I expected:

PATH_INFO - /action
SCRIPT_NAME - (not present)
$c->req->base - http://localhost/
$c->uri_for( $c->action ) - http://localhost/action

The old Catalyst::Engine::SCGI code addressed this kind of issue in
its prepare_path method. Not sure if that's still the recommended way
(that method has been removed from the CPAN release), but perhaps
something like the following would be sufficient (untested):

sub prepare_path {
    my( $self, $c ) = @_;
    my $env = $self->env;
    if( $env->{PATH_INFO} && $env->{SCRIPT_NAME} && $env->{PATH_INFO}
eq $env->{SCRIPT_NAME} ) {
        delete $env->{SCRIPT_NAME};
    }
    return $self->next::method( $c );
}



More information about the Catalyst mailing list