如何使用Perl的CGI.pm识别协议(http与https)

前端之家收集整理的这篇文章主要介绍了如何使用Perl的CGI.pm识别协议(http与https)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在编辑一个在HTTPS下运行时进行特殊处理的Perl CGI应用程序.

现在,我试图通过在请求URI中手动查找“https://”来检测它:

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

有一个稍微清洁的方式这样做?

解决方法

根据 the documentation,CGI.pm有一个https()方法

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环境变量列表.

原文链接:https://www.f2er.com/Perl/241654.html

猜你在找的Perl相关文章