How to fetch HTTP headers in perl when using CGI

前端 未结 2 1869
深忆病人
深忆病人 2020-12-20 17:33

I\'m using Perl/CGI/Apache and want to fetch the X-Forwarded-For HTTP header. How do I do that?

2条回答
  •  盖世英雄少女心
    2020-12-20 18:06

    Except for a few headers that are handled specially, CGI stores the value of Header-Name: in the environment variable HTTP_HEADER_NAME. So, X-Forwarded-For (if present in the request) should be found in $ENV{HTTP_X_FORWARDED_FOR}.

提交回复
热议问题