You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nathan Wiger <na...@west.sun.com> on 2001/09/11 02:05:09 UTC
POST params with
Hey all-
I'm beating my head against this issue, and I can't seem to figure it
out. The problem is I have a <Location> block with a PerlHandler for a
ticketing system app I'm writing:
<Location /tickets>
SetHandler perl-script
PerlHandler Apache::TicketSystem
</Location>
I'm using Apache::Request to access the params with this simple code:
sub handler {
my $r = Apache::Request->new(shift());
my %args = %{ $r->param };
# more code ...
}
When I call the app with GET params, everything works fine. When I use
POST, though, I don't get anything in %args. Reading the manpage for
Apache::Request it looks like I should automatically get the params, ala
CGI.pm. Oh yeah, and CGI.pm doesn't work either, so it doesn't seem to
be an Apache::Request problem.
Am I doing something wrong? Does <Location> not support POST params? All
the packages are at the latest rev as far as I'm aware.
perl 5.6.1
apache 1.3.20
mod_perl 1.25
libapreq 0.33
Thanks for any help.
-Nate
--
Nathan Wiger
Sysadmin and Perl Hacker
Sun Microsystems
Database connection errors in modperl
Posted by Chris Pizzo <ch...@artinside.com>.
Hi everyone,
I'm a bit of a novice here and I'm having a strange problem. I'm using
apache 1.3.20 with modperl 1.26 and embperl 1.3.3 and postgres 7.02. Every
once in a while I get:
Internal Server Error
[11274]ERR: 32: Line 165: Warning in Perl code: DBD::Pg::db selectrow_array
failed: no statement executing at
/opt/apache/htdocs/bmg_graphics/trade/existingtrade_tracking.ehtml line 184.
[11274]ERR: 24: Line 165: Error in Perl code: DBD::Pg::db selectrow_array
failed: no statement executing at
/opt/apache/htdocs/bmg_graphics/trade/existingtrade_tracking.ehtml line 184.
Apache/1.3.20 (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6a mod_perl/1.26
HTML::Embperl 1.3.3 [Mon Sep 10 20:41:56 2001]
but if i refresh the page everything loads correct. Any idea what's causing
this?
Thanks in advance for any help you can give.
Chris Pizzo
Re: POST params with (solved)
Posted by Nathan Wiger <na...@west.sun.com>.
Tom Servo wrote:
>
> There could be something I'm missing here, but I believe you need to use
> $r->content() to get POST arguments. Beware though, that once you call
> content() you can't call it again, so hang onto whatever comes out of it.
>
> Also...isn't it $r->args() or am I just completely missing something here?
Yeah, but if you use Apache::Request then you get a param() method which
works just like CGI.pm's. That is, it transparently gives you your
params whether they're POST/GET/whatever. It also works really nicely
with uploads.
Anyways, it was a stoopid mistake, which you hit on in your reply. I had
a module using a module using a module which was using CGI. Once I
wrapped it in a check for MOD_PERL everything works.
Thanks,
Nate
Re: POST params with
Posted by Tom Servo <to...@cnw.com>.
There could be something I'm missing here, but I believe you need to use
$r->content() to get POST arguments. Beware though, that once you call
content() you can't call it again, so hang onto whatever comes out of it.
Also...isn't it $r->args() or am I just completely missing something here?
You can always do the whole $r->method() eq 'GET' ? $r->args() :
$r->content(); dealy-bob too...
------------
Brian Nilsen
tomservo@cnw.com
On Mon, 10 Sep 2001, Nathan Wiger wrote:
> Hey all-
>
> I'm beating my head against this issue, and I can't seem to figure it
> out. The problem is I have a <Location> block with a PerlHandler for a
> ticketing system app I'm writing:
>
> <Location /tickets>
> SetHandler perl-script
> PerlHandler Apache::TicketSystem
> </Location>
>
> I'm using Apache::Request to access the params with this simple code:
>
> sub handler {
> my $r = Apache::Request->new(shift());
> my %args = %{ $r->param };
>
> # more code ...
> }
>
> When I call the app with GET params, everything works fine. When I use
> POST, though, I don't get anything in %args. Reading the manpage for
> Apache::Request it looks like I should automatically get the params, ala
> CGI.pm. Oh yeah, and CGI.pm doesn't work either, so it doesn't seem to
> be an Apache::Request problem.
>
> Am I doing something wrong? Does <Location> not support POST params? All
> the packages are at the latest rev as far as I'm aware.
>
> perl 5.6.1
> apache 1.3.20
> mod_perl 1.25
> libapreq 0.33
>
> Thanks for any help.
>
> -Nate
>
> --
> Nathan Wiger
> Sysadmin and Perl Hacker
> Sun Microsystems
>