accessing environment variables in Mod-Perl
Eliyahu Cohen
eliyahu.cohen1 at gmail.com
Tue Apr 13 13:47:06 IDT 2010
How can mod-perl access environment variables set by other Apache modules? I
tried the following:
in the virtual host config I set:
SetEnvIf Request_URI "\.html$" TE=TEST
PerlRequire "/opt/modperl/TE/ST.pm"
PerlOutputFilterHandler TE::ST
the contents of /opt/modperl/TE/ST.pm is as follows:
======================================================================
package TE::ST;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use APR::Table ();
BEGIN { push @INC, "/opt/modperl/"; }
use Apache2::Const -compile => qw(OK);
use constant BUFF_LEN => 1024;
sub handler
{
my $f = shift;
unless ($f->ctx)
{
while ($f->read(my $buffer, BUFF_LEN))
{
$buffer =~ s/It/Eli/g;
$buffer .= $ENV{"TE"};
$f->print($buffer);
}
return Apache2::Const::OK;
}
}
1;
The 'It' in the index.html file is changed properly, but I the
'TE' environment variable setup by SetEnvIf does not show up. Any ideas what
I'm missing?
Thanks,
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20100413/fc195196/attachment.html>
More information about the Linux-il
mailing list