我正在编辑一个在 HTTPS 下运行时执行特殊处理的 Perl CGI 应用程序。
现在,我正在尝试通过在请求 URI 中手动查找“https://”来检测它:
my $is_secure = $cgi->request_uri =~ m{^https://};
有没有更清洁的方法来做到这一点?
最佳答案
CGI.pm 有 https()
方法,根据 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.
这可能是您正在寻找的。如果没有参数,它会返回 HTTPS 环境变量列表。
关于perl - 如何使用 Perl 的 CGI.pm 识别协议(protocol)(http 与 https),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5223341/