Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I identify the protocol (http vs. https) using Perl's CGI.pm

Tags:

cgi

perl

I'm editing a Perl CGI application that does special processing when run under HTTPS.

Right now, I'm trying to detect it by manually looking for 'https://' in the request URI:

    my $is_secure = $cgi->request_uri =~ m{^https://};

Is there a slightly cleaner way of doing this?

like image 440
Anirvan Avatar asked Mar 07 '11 18:03

Anirvan


1 Answers

CGI.pm has an https() method that, according to the documentation:

operates on the HTTPS environment variables present when the SSL protocol is in effect. Can be used to determine whether SSL is turned on.

This is probably what you're looking for. Without parameters, it returns a list of HTTPS environment variables.

like image 117
CanSpice Avatar answered Oct 20 '22 02:10

CanSpice