Skip Menu |

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 86058
Status: resolved
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: SAPER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 5.90020
  • 5.90030
Fixed in: (no value)



Subject: uri_for() calculates incorrect paths under recent Lighttpd
Hello, Properly reporting here what I said on IRC. Context: trying to deploy a working web application, made with Catalyst 5.8 and currently running via FastCGI under Lighttpd onto a new server. current servers: Debian 5.0 lenny, Lighttpd 1.4.19, Catalyst 5.80015, Perl 5.10.0 new servers: Debian 7.0 wheezy, Lighttpd 1.4.31, Catalyst 5.90030, Perl 5.14.2 When trying to run the application, it appears that uri_for() returns inccorect paths, duplicating the path, therefore generating incorrect URLs which end up 404. Here are the steps to reproduce the problem from scratch: $ cd /home/voice/current/cgi-bin $ catalyst.pl Derpy $ cd Derpy $ script/derpy_create.pl controller Muffin $ patch -p0 < ../Derpy-muffin.diff # see attached file $ sudo service lighttpd restart # using attached lighty config $ curl -s http://derpy.your.hostname/muffin | head -2 <html><body><pre> c.uri_for('/muffin') = http://derpy.your.hostname/muffin/muffin "I just don't know what went wrong", but it looks very wrong even to my Catalyst newbie eyes. Happy Derpy, unhappy me http://fc09.deviantart.net/fs70/i/2012/285/5/5/muffin__by_tsitra360-d5hmvem.jpg Just in case, the complete c.request.env dump: $ curl http://derpy.your.hostname/muffin <html><body><pre> c.uri_for('/muffin') = http://derpy.your.hostname/muffin/muffin DOCUMENT_ROOT = /home/voice/trunk/cgi-bin/Derpy/ FCGI_ROLE = RESPONDER GATEWAY_INTERFACE = CGI/1.1 HTTP_ACCEPT = */* HTTP_HOST = derpy.your.hostname HTTP_USER_AGENT = curl/7.26.0 PATH_INFO = QUERY_STRING = REDIRECT_STATUS = 200 REMOTE_ADDR = 192.168.21.206 REMOTE_PORT = 54995 REQUEST_METHOD = GET REQUEST_URI = /muffin SCRIPT_FILENAME = /home/voice/trunk/cgi-bin/Derpy/muffin SCRIPT_NAME = /muffin SERVER_ADDR = 192.168.21.206 SERVER_NAME = derpy.your.hostname SERVER_PORT = 80 SERVER_PROTOCOL = HTTP/1.1 SERVER_SOFTWARE = lighttpd/1.4.31 psgi.errors = IO::Handle=GLOB(0x3ed6c38) psgi.input = IO::Handle=GLOB(0x3ed6b90) psgi.multiprocess = 1 psgi.multithread = psgi.nonblocking = psgi.run_once = psgi.streaming = 1 psgi.url_scheme = http psgi.version = ARRAY(0x3b4cf18) psgix.harakiri = </pre></body></html> t0m suggested me to manually enable Plack::Middleware::LighttpdScriptNameFix, but I don't see how to do that with the script/derpy_fastcgi.pl generated by Catalyst 5.9. In the module documentation, Miyagawa points to Lighttpd's option fix-root-scriptname, but it has no effect. Regards -- Close the world, txEn eht nepO.
Subject: Derpy-muffin.diff
--- lib/Derpy/Controller/Muffin.pm 2013-06-11 14:18:43.767466001 +0200 +++ lib/Derpy/Controller/Muffin.pm 2013-06-11 14:15:27.579466003 +0200 @@ -24,10 +24,22 @@ sub index :Path :Args(0) { my ( $self, $c ) = @_; - $c->response->body('Matched Derpy::Controller::Muffin in Muffin.'); + $c->forward('muffin'); } +sub muffin :Local :Args(0) { + my ( $self, $c ) = @_; + + my $body = "c.uri_for('/muffin') = " . $c->uri_for('/muffin') . "\n\n"; + + my $env = $c->request->env; + $body .= join $/, map "$_ = $env->{$_}", sort keys %$env; + $body = "<html><body><pre>\n$body\n</pre></body></html>\n"; + + $c->response->body($body); +} + =head1 AUTHOR A clever guy
Subject: derpy.lighty.conf
Download derpy.lighty.conf
application/octet-stream 755b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #86058] AutoReply: uri_for() calculates incorrect paths under recent Lighttpd
Date: Tue, 11 Jun 2013 17:37:51 +0200 (CEST)
To: bug-Catalyst-Runtime [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <sebastien [...] aperghis.net>
So, it seems that a bugfix from 5.90007, which enables the Lighttpd script name fix only on old versions, is what prevents my example Catalyst app from working within Lighttpd 1.4.31: - Lighttpd script name fix is only applied for lighttpd versions < 1.4.23. This should fix non-root installs of lighttpd in versions over that. t0m's suggestion is therefore to correct that using the Plack middleware hotfix: ----- derpy.psgi ----------------------------------------------- use strict; use warnings; use Derpy; use Plack::Middleware::LighttpdScriptNameFix; my $app = Plack::Middleware::LighttpdScriptNameFix->wrap( Derpy->apply_default_middlewares(Derpy->psgi_app)); $app; ---------------------------------------------------------------- Replacing the original derpy.psgi with this one finally generates more appropriate URLs: $ curl -s http://derpy.saperghis-vm.cpt-dev-v1.voice.dabcnet.cpt/muffin | head -5 <html><body><pre> c.uri_for('/muffin') = http://derpy.saperghis-vm.cpt-dev-v1.voice.dabcnet.cpt/muffin c.request.uri = http://derpy.saperghis-vm.cpt-dev-v1.voice.dabcnet.cpt/muffin c.request.base = http://derpy.saperghis-vm.cpt-dev-v1.voice.dabcnet.cpt/ And adding a corresponding .psgi file in the original Catalyst application (generated with Catalyst 5.8), also makes it works correctly. t0m++ for his patience, finding the origin of the problem, and providing what is a awfully simple fix. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
On Tue Jun 11 11:38:18 2013, sebastien@aperghis.net wrote: Show quoted text
> So, it seems that a bugfix from 5.90007, which enables the Lighttpd > script name fix only on old versions, is what prevents my example > Catalyst app from working within Lighttpd 1.4.31: > > - Lighttpd script name fix is only applied for lighttpd versions > < 1.4.23. This should fix non-root installs of lighttpd in versions > over that. > > t0m's suggestion is therefore to correct that using the Plack > middleware hotfix: > > ----- derpy.psgi ----------------------------------------------- > use strict; > use warnings; > > use Derpy; > > use Plack::Middleware::LighttpdScriptNameFix; > my $app = Plack::Middleware::LighttpdScriptNameFix->wrap( > Derpy->apply_default_middlewares(Derpy->psgi_app)); > > $app; > ---------------------------------------------------------------- > > Replacing the original derpy.psgi with this one finally generates more > appropriate URLs: > > $ curl -s http://derpy.saperghis-vm.cpt-dev- > v1.voice.dabcnet.cpt/muffin | head -5 > <html><body><pre> > c.uri_for('/muffin') = http://derpy.saperghis-vm.cpt-dev- > v1.voice.dabcnet.cpt/muffin > > c.request.uri = http://derpy.saperghis-vm.cpt-dev- > v1.voice.dabcnet.cpt/muffin > c.request.base = http://derpy.saperghis-vm.cpt-dev- > v1.voice.dabcnet.cpt/ > > > And adding a corresponding .psgi file in the original Catalyst > application > (generated with Catalyst 5.8), also makes it works correctly. > > > t0m++ for his patience, finding the origin of the problem, and > providing > what is a awfully simple fix.
I'm going to close this since it looks to me that the move to PSGI core and some related updates fixed this issue. If not please reopen and let me know.