Reif Peter wrote:

> In a mod_perl handler I want to construct the original URL of the request. I
> can construct it with r->get_server_name, r->get_server_port, r->uri and
> $r->parsed_uri->query.
> 
> But how do I get the protocol, http or https.  Is there a way to find out
> whether SSLEngine On is set?
> 
> Yes, I can set it with "PerlSetVar protocol https", but is there a simpler
> way?


There was a long related discussion a few weeks ago. Here is what I've 
added to the guide (not online yet):


=head1 Verifying Whether A Request Was Received Over An SSL Connection

Just like C<$ENV{MODPERL}> is checked to see whether the code is run
under mod_perl, C<$ENV{HTTPS}> is set by ssl modules and therefore can
be used to check whether a request is running over SSL connection. For
example:

   print "SSL" if $ENV{HTTPS};

If C<PerlSetupEnv Off> setting is in effect, C<$ENV{HTTPS}> won't be
available, and then:

   print "SSL" if $r->subprocess_env('https');

should be used instead.

Note that it's also possible to check the scheme:

   print "SSL" if Apache::URI->parse($r)->scheme =~ m/^https/;

but it's not one hundred percent certain unless you control the server
and you know that you run a secure server on the port 443.






-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/

Reply via email to