Skip Menu |

This queue is for tickets about the CGI-Application-Dispatch-PSGI CPAN distribution.

Report information
The Basics
Id: 67237
Status: open
Priority: 0/
Queue: CGI-Application-Dispatch-PSGI

People
Owner: Nobody in particular
Requestors: earino [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.2
Fixed in: (no value)



Subject: CGI::Application::Dispatch::PSGI does not set HTTP_REQUEST in environment.
When using CGI::Application::Dispatch::PSGI as per the example in CGI::Application::Demo::Dispatch, with Starman, it fails to work when the dispatch routes have HTTP method qualifiers. For example, the code looks like this: my($app) = CGI::Application::Dispatch -> as_psgi ( prefix => 'CGI::Application::Demo::Dispatch', table => [ '' => {app => 'Menu', rm => 'display'}, ':app' => {rm => 'initialize'}, ':app/:rm' => {}, ], ); If this is changed to: my($app) = CGI::Application::Dispatch -> as_psgi ( prefix => 'CGI::Application::Demo::Dispatch', table => [ '' => {app => 'Menu', rm => 'display'}, ':app[get]' => {rm => 'initialize'}, #NOTE THE METHOD ':app/:rm' => {}, ], ); This will fail, as CGI::Application::Dispatch will complain that on line 400 it failed to append a string: $rm .= "_$http_method"; because it failed to get the $http_method: my $http_method = $self->_http_method; Because that sub is as follows: sub _http_method { IS_MODPERL ? shift->_r->method : ($ENV{HTTP_REQUEST_METHOD} || $ENV{REQUEST_METHOD}); } and unfortunately, the as_psgi method does not set either HTTP_REQUEST_METHOD or REQUEST_METHOD in %ENV. I believe the attached patch will do what is needed.
Subject: fix-psgi-not-setting-request-method.diff
--- PSGI.pm.orig 2011-04-04 17:21:08.000000000 -0500 +++ PSGI.pm 2011-04-04 17:32:46.000000000 -0500 @@ -77,6 +77,8 @@ $args{args_to_new}->{QUERY} = CGI::PSGI->new($env); local $ENV{PATH_INFO} = $env->{PATH_INFO}; + local $ENV{REQUEST_METHOD} = $env->{REQUEST_METHOD}; + local $ENV{HTTP_REQUEST_METHOD} = $env->{HTTP_REQUEST_METHOD}; $self->dispatch(%args); };
Subject: Re: [rt.cpan.org #67237] CGI::Application::Dispatch::PSGI does not set HTTP_REQUEST in environment.
Date: Wed, 06 Apr 2011 08:41:00 -0400
To: bug-CGI-Application-Dispatch-PSGI [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Thanks for the patch! Mark