Empty 'body' when POST and CGI under Apache #837

Open
knutov opened this Issue Oct 3, 2012 · 1 comment

Projects

None yet

1 participant

@knutov

This is connected with #832.

cat .htaccess

Options +ExecCGI

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.(swf)|(jpg)|(png)|(gif)$
RewriteRule ^(.+)$ /dispatch.cgi/$1 [L,QSA]

Note: this is .cgi.

Right version of dispatch.cgi is:

#!/usr/bin/env perl
use Dancer ':syntax';
use FindBin '$RealBin';
use Plack::Runner;

set apphandler => 'PSGI';
# set environment => 'production';
set environment => 'development';

$ENV{SCRIPT_NAME} = '';

my $psgi = path($RealBin, '..', 'bin', 'app.pl');
die "Unable to read startup script: $psgi" unless -r $psgi;

Plack::Runner->run($psgi);

Note the $ENV{SCRIPT_NAME} = ''; - this is important. Everething will be redirected to http://.../dispatch.cgi/the/requested/path/ unless this string, which is, usual, undesired.

And everething looks fine with this, except POST request.

When running with starman I've got 'psgi.input' => bless( \*{'Plack::TempBuffer:erlIO::$io'}, 'FileHandle' ) and 'body' parsed correctly.

In CGI mode when running via Plack::Runner->run($psgi);
I see
'psgi.input' => *::STDIN
and 'body' => '' in this case.

All POST data is not parsed in this case.

Are any known solution for this?


Additionally, for fastcgi mode, I have to add
request->{env}->{SCRIPT_NAME} = ''; to hook 'before'. May be it's better to not use %ENV{SCRIPT_NAME} at all? I can not imagine case when it needed - it is not possible to write something without "friendly urls" in Dancer.

@knutov

This problem still exists.

# cpanm Plack
Plack is up to date. (1.0013)

# cpanm Dancer
Dancer is up to date. (1.3110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment