You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Erik Norgaard <no...@locolomo.org> on 2006/09/28 10:03:05 UTC
Getting post data
Hi:
I am using Apache 2.2 with mod_perl2. Reading the documentation I have
found that I should get POST data using read():
$r->read($buffer, $r->headers_in('content-length'))
A few questions - ok, some may really be related to the http protocol:
1) Is the headers_in case sensitive? (content-length ne Content-Length)?
2) Once in, any tricks or modules for parsing the data?
3) How about file-uploads, are these binary or base64?
4) How do I efficiently handle large posts (such as file uploads)?
I know I could bang my head against the keyboard and eventually get some
working code out, but it seems that these are quite general issues, so
some solution must exist.
Other question: modperlbook.org is down, is there a mirror or place I
can download it?
Thanks, Erik
--
Ph: +34.666334818 web: http://www.locolomo.org
X.509 Certificate: http://www.locolomo.org/crt/8D03551FFCE04F0C.crt
Key ID: 69:79:B8:2C:E3:8F:E7:BE:5D:C3:C3:B1:74:62:B8:3F:9F:1F:69:B9
Re: Getting post data
Posted by Lionel MARTIN <ma...@hotmail.com>.
Hi,
You should use libapreq2, which is a library that globally allows to deal
with data submitted by the client.
You can find documentation about it here:
http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm
Concerning CGI.pm, except if you are already using it for other purposes, I
would advise you not to load and use it, and use libapreq2 instead which is
(far) lighter and more efficient.
Re large data uploads efficiency, I'm not able to reply right now, but I'm
sure others in this list could provide a reply.
Lionel.
----- Original Message -----
From: "Erik Norgaard" <no...@locolomo.org>
To: <mo...@perl.apache.org>
Sent: Thursday, September 28, 2006 10:03 AM
Subject: Getting post data
> Hi:
>
> I am using Apache 2.2 with mod_perl2. Reading the documentation I have
> found that I should get POST data using read():
>
> $r->read($buffer, $r->headers_in('content-length'))
>
> A few questions - ok, some may really be related to the http protocol:
>
> 1) Is the headers_in case sensitive? (content-length ne Content-Length)?
>
> 2) Once in, any tricks or modules for parsing the data?
>
> 3) How about file-uploads, are these binary or base64?
>
> 4) How do I efficiently handle large posts (such as file uploads)?
>
> I know I could bang my head against the keyboard and eventually get some
> working code out, but it seems that these are quite general issues, so
> some solution must exist.
>
> Other question: modperlbook.org is down, is there a mirror or place I can
> download it?
>
> Thanks, Erik
>
> --
> Ph: +34.666334818 web: http://www.locolomo.org
> X.509 Certificate: http://www.locolomo.org/crt/8D03551FFCE04F0C.crt
> Key ID: 69:79:B8:2C:E3:8F:E7:BE:5D:C3:C3:B1:74:62:B8:3F:9F:1F:69:B9
>
Re: Getting post data
Posted by Greger <bo...@gregerhaga.net>.
On Thu, 28 Sep 2006 10:06:05 +0200, Tom Schindl wrote
> Hi,
>
> Please use one of the modules to read data:
> - libapreq2 (http://search.cpan.org/~joesuf/libapreq2-2.08/)
> - CGI.pm (comes with your perl-distro maybe you need to update it
> from CPAN if you have an older perl)
>
> Tom
>
> Erik Norgaard schrieb:
> > Hi:
> >
> > I am using Apache 2.2 with mod_perl2. Reading the documentation I have
> > found that I should get POST data using read():
> >
> > $r->read($buffer, $r->headers_in('content-length'))
> >
> > A few questions - ok, some may really be related to the http protocol:
> >
> > 1) Is the headers_in case sensitive? (content-length ne Content-Length)?
> >
> > 2) Once in, any tricks or modules for parsing the data?
> >
> > 3) How about file-uploads, are these binary or base64?
> >
> > 4) How do I efficiently handle large posts (such as file uploads)?
> >
> > I know I could bang my head against the keyboard and eventually get some
> > working code out, but it seems that these are quite general issues, so
> > some solution must exist.
> >
> > Other question: modperlbook.org is down, is there a mirror or place I
> > can download it?
> >
> > Thanks, Erik
> >
to use CGI you do:
in the handler
use CGI;
sub handler
{
my $r = shift;
my $cgi = CGI->new($r);
then you can get the parameters like
my $someparamvalue=$cgi->param("someparam");
}
there is also a way of getting the data from the $r object ( that is:not using
the CGI package ), but can't remember right now how to do that, perhaps
someone else could tell, please?
--
QxRSSReader v1.2.6a released (30-06-2006)
PortScanner v1.2.2 ( 09-08-2006 )
http://www.gregerhaga.net/
There are no stupid questions, but there are stupid answers.
Re: Getting post data
Posted by Erik Norgaard <no...@locolomo.org>.
Tom Schindl wrote:
> Please use one of the modules to read data:
> - libapreq2 (http://search.cpan.org/~joesuf/libapreq2-2.08/)
> - CGI.pm (comes with your perl-distro maybe you need to update it from
> CPAN if you have an older perl)
Thanks! Apache2::Request is just what I need - I understand that this is
more efficient than CGI or compat.
Cheers, Erik
--
Ph: +34.666334818 web: http://www.locolomo.org
X.509 Certificate: http://www.locolomo.org/crt/8D03551FFCE04F0C.crt
Key ID: 69:79:B8:2C:E3:8F:E7:BE:5D:C3:C3:B1:74:62:B8:3F:9F:1F:69:B9
Re: Getting post data
Posted by Tom Schindl <li...@bestsolution.at>.
Hi,
Please use one of the modules to read data:
- libapreq2 (http://search.cpan.org/~joesuf/libapreq2-2.08/)
- CGI.pm (comes with your perl-distro maybe you need to update it from
CPAN if you have an older perl)
Tom
Erik Norgaard schrieb:
> Hi:
>
> I am using Apache 2.2 with mod_perl2. Reading the documentation I have
> found that I should get POST data using read():
>
> $r->read($buffer, $r->headers_in('content-length'))
>
> A few questions - ok, some may really be related to the http protocol:
>
> 1) Is the headers_in case sensitive? (content-length ne Content-Length)?
>
> 2) Once in, any tricks or modules for parsing the data?
>
> 3) How about file-uploads, are these binary or base64?
>
> 4) How do I efficiently handle large posts (such as file uploads)?
>
> I know I could bang my head against the keyboard and eventually get some
> working code out, but it seems that these are quite general issues, so
> some solution must exist.
>
> Other question: modperlbook.org is down, is there a mirror or place I
> can download it?
>
> Thanks, Erik
>
Re: Getting post data
Posted by Malcolm J Harwood <mj...@liminalflux.net>.
On Thursday 28 September 2006 04:03, Erik Norgaard wrote:
(I don't recall seeing a response to this, apologies if I'm duplicating).
> I am using Apache 2.2 with mod_perl2. Reading the documentation I have
> found that I should get POST data using read():
>
> $r->read($buffer, $r->headers_in('content-length'))
Don't do that unless you really need to for some reason. (see below)
> A few questions - ok, some may really be related to the http protocol:
>
> 1) Is the headers_in case sensitive? (content-length ne Content-Length)?
I believe so.
> 2) Once in, any tricks or modules for parsing the data?
CGI.pm and libapreq both provide methods for getting the data, you don't read
it yourself, you just ask the module for the data and it hands it to you
pre-parsed.
> 3) How about file-uploads, are these binary or base64?
It doesn't matter, use one of the above and it'll handle it all for you and
give you the data.
> 4) How do I efficiently handle large posts (such as file uploads)?
I believe libapreq is faster than CGI.pm, is that what you meant?
> I know I could bang my head against the keyboard and eventually get some
> working code out, but it seems that these are quite general issues, so
> some solution must exist.
Yup.
> Other question: modperlbook.org is down, is there a mirror or place I
> can download it?
It seems to be up now.