You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark Deepak Puttnam <ma...@freightlist.com> on 2003/07/31 21:44:06 UTC
Accessing environment variables prior to invoking the content
handler.
Hi Group,
I have a need to access all the %ENV (cgi,mod_perl sent by the client)
variables prior to invoking the content handler. I am using the modperl
environment by running the cgi scripts under Perl::Registry. I wish to
use the PerlTransHandler to check if the request for page A has
orginated from page B. If it did then redirect to page C.
I have used the following code in the in my handler and I still do not
get the values. This was recommended by the "Writing Apache Modules by
Doug M and Lincoln S."
sub handler {
my $r=shift;
my $env=$r->subprocess_env;
%ENV=%$senv;
my $referer=$ENV{'HTTP_REFERER'};
xxxx
xxxxx
}
Thank you for the help in advance.
Mark
Re: Accessing environment variables prior to invoking the content
handler.
Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2003-07-31 at 15:44, Mark Deepak Puttnam wrote:
> I have used the following code in the in my handler and I still do not
> get the values.
Do you get anything at all? HTTP_REFERER is not always sent by
browsers.
- Perrin
Re: Accessing environment variables prior to invoking the content
handler.
Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
> On Thu, 2003-07-31 at 15:44, Mark Deepak Puttnam wrote:
>
>>sub handler {
>> my $r=shift;
>> my $env=$r->subprocess_env;
>> %ENV=%$senv;
>>
>> my $referer=$ENV{'HTTP_REFERER'};
>>
>> xxxx
>> xxxxx
>>
>>
>> }
>
>
> Come to think of it, you should just use the Apache API for this:
>
> my $referer = $r->header_in("Referer");
BTW, header_in, header_out and err_header_out are sort of "deprecated", since
mp1 and mp2 both have headers_in, headers_out and err_headers_out. so if you
write your mp1 code using the latter ones, it'll be easier to move to mp2.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Accessing environment variables prior to invoking the content
handler.
Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2003-07-31 at 15:44, Mark Deepak Puttnam wrote:
> sub handler {
> my $r=shift;
> my $env=$r->subprocess_env;
> %ENV=%$senv;
>
> my $referer=$ENV{'HTTP_REFERER'};
>
> xxxx
> xxxxx
>
>
> }
Come to think of it, you should just use the Apache API for this:
my $referer = $r->header_in("Referer");
- Perrin