Chris Datfung wrote:
I want to use mod-perl to edit server responses under certain conditions. My
plan was to use various modules, like mod-setenvif and mod-security to set
an environment variable and then have mod-perl edit the response body only
run when the environment variable is set. I tried the following test which
was supposed to append 'TEST' to my index.html page:
in the virtual host config I have:
SetEnvIf Request_URI "\.html$" TE=TEST
PerlRequire "/opt/modperl/TE/ST.pm"
PerlOutputFilterHandler TE::ST
...
Hi.
Without entering into the details, and without contradiction with your
original line of enquiry and other responses, you may want to have a
look at the alternatives consisting of :
A)
- conditionally adding a HTTP header to the request at an early stage
(using a mod_perl module instead of mod_setenvif e.g.)
- later checking for the presence of that header and deciding to filter
or not
Adding and retrieving headers is easy with mod_perl.
B)
Or use an early-running mod_perl module to conditionally set a "pnote",
and later checking on that pnote.
The first alternative has the advantage (contrary to Apache internal
variables or pnotes) that even if you proxy the request to another
server, the value you set in the additional HTTP request header is
visible to that other server.
The second is probably more efficient, since you are running mod_perl
anyway, as long as this is within the same server.