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->[EMAIL PROTECTED];
  $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: [EMAIL PROTECTED]

Reply via email to