[Catalyst] Lighttpd pathing solved

Mark Blythe list at markblythe.com
Fri Jun 23 07:26:12 CEST 2006

After much debugging, I finally was able to fix the problem I was having
with lighttpd + FastCGI.  See original message below for details.  What it
boils down to is that lighttpd seems to report in SCRIPT_NAME (environment
var) what some other web servers report in PATH_INFO.  This was causing
$c->req->path to be set to nothing for URLs which end in a slash, such as:


The result was that these requests were always dispatched to my
application's default action.

I was able to write a small plugin that fixes this issue without breaking
the dev server script.  The guts of the plugin are:

sub handle_request {
        my ($class, %args) = @_;

        if (exists $args{env}) {
                # lighttpd seems to report these backward
                $args{env}{PATH_INFO} ||= delete $args{env}{SCRIPT_NAME};


Are there any other lighttpd users out there who have had this trouble?  If
so, would this plugin be useful for anybody else?

---------- Forwarded message ----------
From: Mark Blythe <list at markblythe.com>
Date: Jun 22, 2006 12:08 AM
Subject: Path handling inconsistencies?
To: The elegant MVC web framework <catalyst at lists.rawmode.org>

I'm seeing a difference in how paths are handled when running under the test
server (myapp_server.pl) vs lighttpd/FastCGI.  For instance, I have an
action defined as:

sub bar : Regex('^foo/(\d+)/bar/(\d+)$') {

It's supposed to take two numeric ID's in the URL.  If I test with the
following URL:


It works in both the dev server and FastCGI.  I see the following line in
debug output:

[Wed Jun 21 23:50:22 2006] [catalyst] [debug] "GET" request for
"foo/1/bar/2" from ""

However, if I add a trailing slash to the URL:


It works in the dev server, but *not* in FastCGI.  Somehow, this causes it
not to match.  I get this puzzling entry in the FastCGI debug output:

[Wed Jun 21 23:53:18 2006] [catalyst] [debug] "GET" request for "" from ""

Any ideas where to start looking for the problem?  I'd guess in one of the
Catalyst::Engine modules, but a first stab at debugging didn't turn up
anything obvious.  I did try removing the trailing $ from my action regex,
but it made no difference.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060622/f932eda1/attachment-0001.htm 

More information about the Catalyst mailing list