perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] trouble reading post using CGI.pm
Date Wed, 01 Oct 2003 22:51:26 GMT
christian@skarby.no wrote:
> 1. Problem Description:
> 
> I have trouble getting iniformation from CGI-forms sent by HTTP/POST. To reproduce 
> the problem; use the testpackage I've written and included in section 5 of this 
> mail. I've also included what I've found relevant from my mod_perl/Apache-setup 
> in section 4.
> 
> My observation is that there is no problem using GET to transfer form-data,
> but no data at all is avaliable through $q->param when using POST.
> 
> I have tested this with different versions of mod_perl (1.99_09, snapshot
> from cvs this sunday and finally 1.99_10 released yesterday) and CGI.pm
> (2.93, 3.00) - as for now I run mod_perl 1.99_10 and CGI.pm 3.0.
> 
> If there is something in my setup that causes this, please point me in the
> right direction or maybe towards the right documentation. - It is not
> totally neccessary for me to use CGI.pm, the most important is to receive
> the data ;)
[...]
> ----BEGIN sample from commonapache2.conf -----
> 	<IfModule mod_perl.c>
> 		PerlOptions +GlobalRequest
> 		PerlModule CGItest
> 		<Location /CGItest>
> 			SetHandler modperl
> 			PerlResponseHandler CGItest
> 		</Location>
> 	</IfModule>
> ----END sample from commonapache2.conf -----

Thanks for a very good bug report, Christian.

The problem is very simple. with 'Sethandler modperl' STDIN is not 
tied/perlio'ed so CGI.pm sees no POSTed data.
http://perl.apache.org/docs/2.0/user/config/config.html#C_SetHandler_

The solution is to use 'SetHandler perl-script'. I guess we may need to 
provide a new PerlOptions to enable tied STDIN/STDOUT on demand.

If you have a bit of spare time, another solution is to fix CGI.pm to use 
$r->read(STDIN...) instead of read(STDIN...) if $r is available. Should be a 
trivial patch. And then submit it to Lincoln (and may be CC the modperl list 
so we can approve it for Lincoln to have a better incentive to include your 
patch ;)

besides, since you use 'CGI->new($r)', i.e., passing $r to CGI.pm you don't 
need PerlOptions +GlobalRequest. Though it's unrelated to your problem.

Once Apache::Request 2.0 will be finished (you can already give it a try as it 
should work, see: http://httpd.apache.org/apreq/) you won't need any of the 
above and it'll just work with 'Sethandler modperl'.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message