如何使用PHP/apache访问原始HTTP请求数据? [英] How can I access the raw HTTP request data with PHP/apache?

查看:105
本文介绍了如何使用PHP/apache访问原始HTTP请求数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以在不运行任何其他扩展的情况下,在Apache上运行的PHP中获取原始HTTP请求数据.我已经在手册中看到了 HTTP 函数,但是没有安装扩展的选项在我的环境中.

I was wondering if there was a way to get at the raw HTTP request data in PHP running on apache that doesn't involve using any additional extensions. I've seen the HTTP functions in the manual, but I don't have the option of installing an extension in my environment.

虽然我可以从$ _SERVER访问信息,但我希望看到的原始请求与发送到服务器的原始请求完全一样. PHP修改标头名称以适合其自身的数组键样式,例如. Some-Test-Header变为HTTP_X_SOME_TEST_HEADER.这不是我所需要的.

While I can access the information from $_SERVER, I would like to see the raw request exactly as it was sent to the server. PHP munges the header names to suit its own array key style, for eg. Some-Test-Header becomes HTTP_X_SOME_TEST_HEADER. This is not what I need.

推荐答案

您是指$_SERVER中包含的信息吗?

Do you mean the information contained in $_SERVER?

print_r($_SERVER);

那会做吗?

foreach(getallheaders() as $key=>$value)  {
    print $key.': '.$value."<br />";
}

这篇关于如何使用PHP/apache访问原始HTTP请求数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆