You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Frank Maas <fr...@cheiron-it.nl> on 2003/02/28 14:15:17 UTC

How to avoid loss of POST data in a good way?

Hi,

Excuse me for this question that is, without question, due to my newbie-
ness, but I am against a wall here. I am creating a website that is running
under mod_perl and using several handlers of the chain. The website uses
the POST method to send form data.
I first used Apache::Request->new() in all handlers, but that made that I
"lost" the posted data after its first use. OK, this was somewhere in the
manuals and books and I changed to instance(). My problem begins when I
use CPAN or other already-made modules that seem not to respect this and
again the posted data got lost.
What is the best solution to avoid this? Another question is: why does new()
not do what instance() does in the first place? Another solution would be
that the posted data is read once and then silently put on a stack so a
next call in the same request-cycle can reuse it?

Related to this issue... (and as newbie as the above): I seem not to be
able to find the connecting two phrases when it is about combining mod_perl
and CGI.pm. CGI.pm is (amongst others) all about reading formdata, persis-
tance and creating webpages. For this it has to read the request. How does
this interfere with my own actions for getting to that information?

To combine all of this in an example application (and I am sorry if it is
really bad):

-->PerlAuthenHandler-------------->PerlHandler-------------->PerlLogHandler-
|
   - retrieve some cookie
   - retrieve some form param's
                                   - use CGI.pm
                                   - retrieve some form param's
                                                             - retrieve some
                                                                   form
param's

Any help is appreciated, even if you flame me to a location where I can
(really...) find this.

--Frank


Re: How to avoid loss of POST data in a good way?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Frank Maas wrote:
> Hi,
> 
> Excuse me for this question that is, without question, due to my newbie-
> ness, but I am against a wall here. I am creating a website that is running
> under mod_perl and using several handlers of the chain. The website uses
> the POST method to send form data.
> I first used Apache::Request->new() in all handlers, but that made that I
> "lost" the posted data after its first use. OK, this was somewhere in the
> manuals and books and I changed to instance(). My problem begins when I
> use CPAN or other already-made modules that seem not to respect this and
> again the posted data got lost.

I have an experimental module that may address your concerns:

http://www.modperlcookbook.org/~geoff/modules/experimental/Apache-CachePOSTRegistry-0.01.tar.gz

it's not documented, but really all you do is replace Apache::Registry with 
Apache::CachePOSTRegistry in your httpd.conf then make sure you use 
Apache::Request->instance() inplace of new().

it's not a complete solution, but it solves the problem of when you want to 
use POST data throughout the request but you need to use CGI.pm or some 
other legacy script for the content phase.

there is some additional information near the end of this talk

http://www.modperlcookbook.org/~geoff/slides/ApacheCon/oo-mod_perl-printable.ppt.gz

HTH

--Geoff