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

标签 perl cgi

我正在编辑一个在 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/

相关文章:

perl - 为什么这里需要两个 `{`?

javascript - 此处文档中的 JQuery 不起作用

python - 让用户上传 Python 脚本执行

regex - Perl:使用 grep 提取文件行的​​模式匹配子字符串

regex - 一个 typedef c 结构的衬里

javascript - 如何通过 Javascript 发送和接收表单数据

CGI.c文件打开

perl - perl 的 eval 函数中的奇怪事情

http - 将 stdout 流式传输到网页

未呈现的 Python 页面