CC: | ch [...] ngmedia.com, hdp [...] cpan.org |
Subject: | POSTing does not work as expected. |
While trying to test CGI code using HTTP::Request::AsCGI as described
in the perl documentation, I found that I needed to set content_length
on the HTTP::Request object because otherwise the CGI application
would receive an empty POST.
my $r = HTTP::Request->new( POST => 'http://192.168.1.1/myapp );
$r->content_type('text/plain');
my $data = '...';
$r->content($data);
$ascgi = HTTP::Request::AsCGI->new($r);
${ $ascgi->enviroment }{REMOTE_ADDR} = '192.168.1.2';
$ascgi->setup;
MyApp::CGI::handler(CGI::Simple->new);
$ascgi->restore;
# (various checks follow here)
I don't see where content_length would be necessary -- shouldn't just
writing $r->content to the stdin file handle suffice? If not, this
requirement to set content_length should be at least documented.
I have tried this with 0.5 version that is currently available in
Debian, but from looking at the code of the 0.9 version, the module's
behavior doesn't appear to have changed.
Cheers,
-Hilko