[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get virtualhost info in mod_perl?



On 26-Oct-06, at 11:59 PM, Kjetil Kjernsmo wrote:

On Thursday 26 October 2006 21:07, Philippe M. Chiasson wrote:
Terry, Jason wrote:
$ENV{‘SERVER_NAME’}

That wold also work.

But in general, I wouldn't recommend using %ENV from within mod_perl,

Can I ask why not? I was of the same opinion, mainly because %ENV is
populated for every request (isn't it?) and so represents an overhead,
but then my colleagues pointed out that if it is there allready, the
penalty has allready been taken, so why not use it?

True, _if_ it's already in %ENV, getting the information out of there is at
virtually no cost. Getting the information out using a more direct API
call also comes at virtually no cost.

Main difference IMO? It's a shorter, more direct path to ask for $r- >header_in->{Host}
that to use %ENV.

To which I had no
good answer. Perhaps %ENV can be turned off entirely?

And that's exactly it. One can do

PerlOptions -SetupEnv

or switch from

SetHandler perl-script
to
SetHandler mod-perl

And all magical (and CGI compatible) %ENV magic will be turned off.

And then that's when some Apache::* module starts behaving strangely,
since it was relying on $ENV{SERVER_NAME}

Hope that clarifies things a bit.

Attachment: PGP.sig
Description: This is a digitally signed message part


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.