perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: http or https in URL?
Date Tue, 06 Nov 2001 15:45:03 GMT
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

   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      mod_perl Guide

View raw message