How to pass the post data to a script

How to pass the post data to a script

am 17.09.2008 09:28:21 von grsvarma019

Hi,

I am using mod_perl2 for authentication.

In this, when a request is made to a script in a particular directory, the
control will go through mod_perl authentication.
Once mod_perl returns OK as a result, we could get to the original script
that we requested.

The real problem here is:

If the requested script of an application needs POST data, that data is not
being sent to the requested script ,but instead it is being captured by
apache request object of the mod_perl.

How can i pass this data to the requested script?

Thanks,
Raja

--
View this message in context: http://www.nabble.com/How-to-pass-the-post-data-to-a-script- tp19526730p19526730.html
Sent from the mod_perl - General mailing list archive at Nabble.com.

Re: How to pass the post data to a script

am 17.09.2008 10:37:30 von torsten.foertsch

On Wed 17 Sep 2008, grsvarma019 wrote:
> If the requested script of an application needs POST data, that data
> is not being sent to the requested script ,but instead it is being
> captured by apache request object of the mod_perl.
>
> How can i pass this data to the requested script?

First, see if libapreq2 can help!

If it doesn't you can try to implement a request input filter that
caches the data on disk while mod_perl does $r->read or
$r->discard_request_body and a second one that reinserts that input for
the script. Not sure if that works.

The first part looks similar to that:

use Apache2::Const -compile=>qw/M_POST OK/;
use APR::Const -compile=>qw/SUCCESS/;
use Apache2::Filter ();
use APR::Bucket ();
use APR::Brigade ();

if( $r->method_number==Apache2::Const::M_POST ) {
my @content;
my $cl=0;
my $rc=$r->add_input_filter( sub {
my ($f, $bb, $mode, $block, $readbytes) = @_;

my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes);
return $rv unless $rv == APR::Const::SUCCESS;

for (my $b = $bb->first; $b; $b = $bb->next($b)) {
$b->read(my $bdata);
$cl+=length $bdata;
push @content, $bdata;
}

return Apache2::Const::OK;
} );
$r->discard_request_body;
$r->pnotes->{rbody}=\@content;
$r->pnotes->{rbody_length}=$cl;
}

Well, it saves the request as pnotes but it shows the principle. The
second part is a bit trickier if not impossible. You'll have to modify
the input filter chain again, insert a filter that creates buckets from
the saved data. But I don't know if that works once EOF has been seen
on input.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

Re: How to pass the post data to a script

am 17.09.2008 11:30:30 von aw

grsvarma019 wrote:
> Hi,
>
> I am using mod_perl2 for authentication.
That is not very specific, but I suppose that you mean that you are
writing your own mod_perl authentication module ?
>
> In this, when a request is made to a script in a particular directory, the
> control will go through mod_perl authentication.
> Once mod_perl returns OK as a result, we could get to the original script
> that we requested.
How does that work exactly ? does it mean that your mod_perl
authentication module sends a login page to the user, then when the
login page is POSTed, it goes to another part of your module that
handles the login, then if it is OK you re-direct to the original script
URL ?
>
> The real problem here is:
>
> If the requested script of an application needs POST data, that data is not
> being sent to the requested script ,but instead it is being captured by
> apache request object of the mod_perl.
Well, that depends on the above.
If you go through another server->browser, browser->server loop before
coming back to the original request, then you have a fundamental
problem, but not exactly the one you probably think.

>
> How can i pass this data to the requested script?
>
The problem you may run against, is that HTTP is essentially a
request-oriented protocol : one request from browser, one answer from
server, and then the server forgets until the next request.
You cannot, in a simple way, "memorise" data on the server side between
one browser request and the next.

One suggestion : have a look at the following module, from CPAN :
Apache2::AuthCookie
and more particularly at the "convert_to_get" subroutine.
That will give you an idea of one possible part of the solution.
That module in itself is also a good base to use for writing your own
system. HTTP authentication can be a lot more complex than one would
think at first.

Re: How to pass the post data to a script

am 18.09.2008 16:03:04 von fjmolinabravo

------=_Part_17700_8602131.1221746584734
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

maybe can help you $r->args()

see you


2008/9/17 grsvarma019

>
> Hi,
>
> I am using mod_perl2 for authentication.
>
> In this, when a request is made to a script in a particular directory, the
> control will go through mod_perl authentication.
> Once mod_perl returns OK as a result, we could get to the original script
> that we requested.
>
> The real problem here is:
>
> If the requested script of an application needs POST data, that data is not
> being sent to the requested script ,but instead it is being captured by
> apache request object of the mod_perl.
>
> How can i pass this data to the requested script?
>
> Thanks,
> Raja
>
> --
> View this message in context:
> http://www.nabble.com/How-to-pass-the-post-data-to-a-script- tp19526730p19526730.html
> Sent from the mod_perl - General mailing list archive at Nabble.com.
>
>

------=_Part_17700_8602131.1221746584734
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

maybe can help you $r->args()

see you


2008/9/17 grsvarma019 <>



Hi,



I am using mod_perl2 for authentication.



In this, when a request is made to a script in a particular directory, the

control will go through mod_perl authentication.

Once mod_perl returns OK as a result, we could get to the original script

that we requested.



The real problem here is:



If the requested script of an application needs POST data, that data is not

being sent to the requested script ,but instead it is being captured by

apache request object of the mod_perl.



How can i pass this data to the requested script?



Thanks,

Raja



--

View this message in context:


Sent from the mod_perl - General mailing list archive at Nabble.com.






------=_Part_17700_8602131.1221746584734--