You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Benoit Caron <be...@netgraphe.com> on 2002/01/09 22:41:39 UTC

Altering ENV from a PerlFixupHandler

I'm trying to set a way of passing some environnement variables from my 
front-end server to my back-end so that my Registry or PerlRun script run 
unchanged. What I've done is that I've modified my frontend to add, with 
mod_rewrite, the environnement data I need (REFERER and REMOTE_ADDR), and I 
tried, on the backend server, to add the value I received in the 
environnement, like that :

      $ENV{$key} = $args{$key};

or also like that :

       $r->subprocess_env($key, $new_value);

My problem is that my change are erased before I get to the Response phase, 
no matter how I set the environnement.

Where did i go wrong? Do I need to add a PerlPassEnv in my httpd.conf? And, 
then, one more place to edit if I want to pass a new Environnnement variables?

And, is that a good way to acheive that?


Benoit Caron
Analyste-Programmeur
Netgraphe - Webfin.com - Le Web Financier
benoit.caron@netgraphe.com
- - - - - - - - - - - - - - - - - - - - - - - -
"The number of Unix installations has grown to 10,
  with more expected."
-- The Unix Programmer's Manual, 2nd edition, June '72


Re: Altering ENV from a PerlFixupHandler

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Benoit Caron wrote:
> 
> I'm trying to set a way of passing some environnement variables from my
> front-end server to my back-end so that my Registry or PerlRun script run
> unchanged. What I've done is that I've modified my frontend to add, with
> mod_rewrite, the environnement data I need (REFERER and REMOTE_ADDR), and I
> tried, on the backend server, to add the value I received in the
> environnement, like that :
> 
>       $ENV{$key} = $args{$key};

that probably won't work.

> 
> or also like that :
> 
>        $r->subprocess_env($key, $new_value);
> 
> My problem is that my change are erased before I get to the Response phase,
> no matter how I set the environnement.

try from a PerlPostReadRequestHandler instead.  you may be running up
against some other mod_perl process.  mod_perl will set up the
environment once per request - typically at the content generation
phase, but there are ways to force it to do so sooner.

that's about all I can think of at the moment...

--Geoff

> 
> Where did i go wrong? Do I need to add a PerlPassEnv in my httpd.conf? And,
> then, one more place to edit if I want to pass a new Environnnement variables?
> 
> And, is that a good way to acheive that?