You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by CrAsH-DMX <cr...@gmail.com> on 2011/01/05 01:09:22 UTC
Problem with PerlTransHandler
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.
Re: Problem with PerlTransHandler
Posted by Torsten Förtsch <to...@gmx.net>.
On Wednesday, January 05, 2011 01:09:22 CrAsH-DMX wrote:
> If comment my $params = $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 then
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
--
Need professional modperl support? Hire me! (http://foertsch.name)
Like fantasy? http://kabatinte.net