Problem with PerlTransHandler

--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<br><br>First of all, I want to clarify that I am pretty newie in mod=
_perl and I'm using mod_perl 1.<br><br>I need to write a module that al=
lows me to capture all the requests that are made to my server, <br>get a s=
tring with all the parameters stored in $r->content or $ r-> args for=
each request, apply <br>
some process and store again in $r->content or $ r->args to follow th=
eir way.<br><br>To achieve this, I'm trying to write a PerlTransHandler=
:<br><br>package Test::test_filter;
<br>use strict;
<br>use Apache::Constants qw(:common);
<br><br>sub handler {
<br>=A0=A0=A0 my $r =3D shift;=A0=A0=A0=A0
<br>=A0=A0=A0 my $params =3D $r->method eq "POST" ? $r->con=
tent:$r->args;
<br>=A0=A0=A0 print STDERR "PARAMS:$params\n";<br>=A0=A0=A0 #DO S=
OMETHING WITH $params<br>=A0=A0=A0 #$r->content($params);
<br>=A0=A0=A0 return DECLINED;
<br>}
<br>1;<br><br>The problem is, after showing the message with the parameters=
in the log file the page with the POST form <br>does not change; this mean=
, don't show me the next page where i should see the values of the modi=
fied parameters.<br>
<br>If comment my $params =3D $r->method eq "POST" ? $r->co=
ntent:$r->args; all works fine.<br><br>I need to do something else?, I&#=
39;m using the right type of handler?<br><br>In advance thank you very much=
for your answers.<br>
<br>

--0016361e7f1c7dab5104990e32dd--
CrAsH-DMX [ Mi, 05 Januar 2011 01:09 ] [ ID #2052594 ]

Re: Problem with PerlTransHandler

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
achieve is not feasible, at least if your handler does not read the message=

body via $r->content.

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

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

Apache2 & Mp2 can do input filtering.

Torsten Förtsch

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

Like fantasy? http://kabatinte.net
torsten.foertsch [ Mi, 05 Januar 2011 14:32 ] [ ID #2052596 ]
Webserver » gmane.comp.apache.mod-perl » Problem with PerlTransHandler

Vorheriges Thema: BerkeleyDB error
Nächstes Thema: [mp2] php response handler clears authenticated user in mod_perl