On Tue, Apr 13, 2010 at 6:34 PM, Fred Moyer <f...@redhotpenguin.com> wrote:

> Correct me if I'm wrong, but don't you need to do this:
>
> PerlPassEnv TE
>
> in your httpd.conf?
>
>
Hey Fred,

That looks correct and I added PerlPassEnv to the virtual host config, but I
still don't see the word 'TEST' when accessing
http://localhost/index.htmlwhile using the TE::ST package shown below.
Am I using $ENV{"TE"}
incorrectly? FWIW, I tried using $ENV{TE} with identical results. I also
added PerlPassEnv HOME to the virtual host config and a '$buffer .=
$ENV{HOME}' to the TE::ST package but did not see the path in the
/index.html output either. Any ideas what I'm missing?

Thanks,

Chris


> On Mon, Apr 12, 2010 at 11:44 AM, Chris Datfung <chris.datf...@gmail.com>
> 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
> > the contents of /opt/modperl/TE/ST.pm is:
> > ======================================================================
> > 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/Chris/g;
> >                         $buffer .= $ENV{"TE"};
> >                         $f->print($buffer);
> >                 }
> >                 return Apache2::Const::OK;
> >         }
> > }
> > 1;
> > ========================================================================
> > The script correctly changes the 'It' in the index.html file to 'Chris'
> but
> > I don't see the value of the 'TE' variable in the response body. Can
> someone
> > point me to an example of how modperl can access environment variables
> set
> > by other apache modules?
> > Thanks,
> > - Chris
>

Reply via email to