Problem with PerlTransHandler

Problem with PerlTransHandler

am 05.01.2011 01:09:22 von CrAsH-DMX

--0016361e7f1c7dab5104990e32dd
Content-Type: text/plain; charset=ISO-8859-1

Hi all

First of all, I want to clarify that I am pretty newie in mod_perl and I'm
using mod_perl 1.

I need to write a module that allows me to capture all the requests that are
made to my server,
get a string with all the parameters stored in $r->content or $ r-> args for
each request, apply
some process and store again in $r->content or $ r->args to follow their
way.

To achieve this, I'm trying to write a PerlTransHandler:

package Test::test_filter;
use strict;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;
my $params = $r->method eq "POST" ? $r->content:$r->args;
print STDERR "PARAMS:$params\n";
#DO SOMETHING WITH $params
#$r->content($params);
return DECLINED;
}
1;

The problem is, after showing the message with the parameters in the log
file the page with the POST form
does not change; this mean, don't show me the next page where i should see
the values of the modified parameters.

If comment my $params = $r->method eq "POST" ? $r->content:$r->args; all
works fine.

I need to do something else?, I'm using the right type of handler?

In advance thank you very much for your answers.

--0016361e7f1c7dab5104990e32dd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi all

First of all, I want to clarify that I am pretty newie in mod=
_perl and I'm using mod_perl 1.

I need to write a module that al=
lows me to capture all the requests that are made to my server,
get a s=
tring with all the parameters stored in $r->content or $ r-> args for=
each request, apply

some process and store again in $r->content or $ r->args to follow th=
eir way.

To achieve this, I'm trying to write a PerlTransHandler=
:

package Test::test_filter;

use strict;

use Apache::Constants qw(:common);


sub handler {

  =A0 my $r =3D shift;    

  =A0 my $params =3D $r->method eq "POST" ? $r->con=
tent:$r->args;

  =A0 print STDERR "PARAMS:$params\n";
  =A0 #DO S=
OMETHING WITH $params
  =A0 #$r->content($params);

  =A0 return DECLINED;

}

1;

The problem is, after showing the message with the parameters=
in the log file the page with the POST form
does not change; this mean=
, don't show me the next page where i should see the values of the modi=
fied parameters.


If comment my $params =3D $r->method eq "POST" ? $r->co=
ntent:$r->args; all works fine.

I need to do something else?, I&#=
39;m using the right type of handler?

In advance thank you very much=
for your answers.




--0016361e7f1c7dab5104990e32dd--

Re: Problem with PerlTransHandler

am 05.01.2011 14:32:54 von torsten.foertsch

On Wednesday, January 05, 2011 01:09:22 CrAsH-DMX wrote:
> If comment my $params =3D $r->method eq "POST" ? $r->content:$r->args; all
> works fine.

My mp1 experience is quite a few years old. But I think what you are trying=
to=20
achieve is not feasible, at least if your handler does not read the message=
=20
body via $r->content.

The problem is a call to $r->content reads the message body. If someone=20
(mod_cgi for example) tries to do that later again it can only read the end=
of=20
file.

If your document is created by a mod_perl handler that uses $r->content the=
n=20
your approach might work. Otherwise if it's a normal CGI script or PHP=20
document I doubt it.

Apache2 & Mp2 can do input filtering.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net