[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: "SetEnv/SetEnvIf" and mod_perl
From:       Paul Silevitch <paul () silevitch ! com>
Date:       2015-10-03 1:08:38
Message-ID: CAEK7ryiWZ+D+O5L2=ik35HcqQCqwjva7gRRjM+VZ4n3AbNMk8w () mail ! gmail ! com
[Download RAW message or body]

subprocess_env method will let you get apache's env:

http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_subprocess_env_

On Fri, Oct 2, 2015 at 6:24 PM, Michael A. Capone <
mcapone@cablewholesale.com> wrote:

> In my code, I do:
>
> <Location something>
>     SetEnvIf Request_URI \.gif$ gif-image
>     SetHandler modperl
>     PerlResponseHandler MyNiftyModule
>     PerlOptions +SetupEnv
> </Location>
>
> And then, yes, I have access to $ENV{'gif-image'}, with a value of "1".
>
> Alternatively, i can
>    SetEnvIf Request_URI \.gif$ gif-image=YES
>
> ... and $ENV{'gif-image'} will have a value of 'YES'.
>
> Note that you have to do
>     PerlOptions +SetupEnv
> in order for this to pass through (as far as i know; unsetting it made my
> custom $ENV's go away).
>
> In a perfect world, we would have "PerlSetEnvIf". :)
>
>
> On 10/02/2015 02:39 AM, André Warnier wrote:
>
>> Hi again.
>>
>> Assuming this kind of configuration :
>>
>> <Location something>
>>     SetEnvIf Request_URI \.gif$ gif-image
>>     SetHandler modperl
>>     PerlResponseHandler MyNiftyModule
>> ..
>> </Location>
>>
>> is there any way, in MyNiftyModule, to "get at" this "gif-image" variable
>> ?
>>
>> Such as, would I find it as $ENV{'gif-image'} ?
>> What kind of thing are these "Apache environment variables" anyway ?
>> I have been using them extensively within Apache itself, but I still
>> can't quite figure out on what plane they live.  Clearly, they are not
>> "environment variables" in the same sense as "cgi-bin environment
>> variables", and not the same thing either as what a "PerlsetVar" does, so
>> what are they ?
>>
>> (And I realise that this is more of an Apache httpd question, but I
>> figure that if someone should be aware of the httpd internals, there is a
>> good chance of finding such a person here).
>>
>>
>>
>>
>

[Attachment #3 (text/html)]

<div dir="ltr">subprocess_env method will let you get apache&#39;s env:<br><br><a \
href="http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_subprocess_env_">h \
ttp://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_subprocess_env_</a><br></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 2, 2015 at 6:24 PM, \
Michael A. Capone <span dir="ltr">&lt;<a href="mailto:mcapone@cablewholesale.com" \
target="_blank">mcapone@cablewholesale.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">In my code, I do:<span class=""><br> <br>
&lt;Location something&gt;<br>
      SetEnvIf Request_URI \.gif$ gif-image<br>
      SetHandler modperl<br>
      PerlResponseHandler MyNiftyModule<br></span>
      PerlOptions +SetupEnv<br>
&lt;/Location&gt;<br>
<br>
And then, yes, I have access to $ENV{&#39;gif-image&#39;}, with a value of \
&quot;1&quot;.<br> <br>
Alternatively, i can<br>
     SetEnvIf Request_URI \.gif$ gif-image=YES<br>
<br>
... and $ENV{&#39;gif-image&#39;} will have a value of &#39;YES&#39;.<br>
<br>
Note that you have to do<br>
      PerlOptions +SetupEnv<br>
in order for this to pass through (as far as i know; unsetting it made my custom \
$ENV&#39;s go away).<br> <br>
In a perfect world, we would have &quot;PerlSetEnvIf&quot;. :)<div \
class="HOEnZb"><div class="h5"><br> <br>
On 10/02/2015 02:39 AM, André Warnier wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> Hi again.<br>
<br>
Assuming this kind of configuration :<br>
<br>
&lt;Location something&gt;<br>
      SetEnvIf Request_URI \.gif$ gif-image<br>
      SetHandler modperl<br>
      PerlResponseHandler MyNiftyModule<br>
..<br>
&lt;/Location&gt;<br>
<br>
is there any way, in MyNiftyModule, to &quot;get at&quot; this &quot;gif-image&quot; \
variable ?<br> <br>
Such as, would I find it as $ENV{&#39;gif-image&#39;} ?<br>
What kind of thing are these &quot;Apache environment variables&quot; anyway ?<br>
I have been using them extensively within Apache itself, but I still can&#39;t quite \
figure out on what plane they live.   Clearly, they are not &quot;environment \
variables&quot; in the same sense as &quot;cgi-bin environment variables&quot;, and \
not the same thing either as what a &quot;PerlsetVar&quot; does, so what are they \
?<br> <br>
(And I realise that this is more of an Apache httpd question, but I figure that if \
someone should be aware of the httpd internals, there is a good chance of finding \
such a person here).<br> <br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic