我正在用 PHP 创建一个框架,我需要让浏览器完成完整的原始请求。所以我想在一个变量中有这样的东西:
POST /lolzorz/xD HTTP/1.1\r\n
Host: localhost\r\n
User-Agent: UserAgentHere/1.0.00\r\n
Content-Type: application/xml; charset=utf-8\r\n
Content-Length: 0\r\n
\r\n
<?xml version="1.0" encoding="UTF-8"?>\r\n
<request>\r\n
<question1 param="value" />\r\n
<question2 param="value" />\r\n
<question3 param="value" />\r\n
</request>\r\n
这可能吗?
我的服务器信息:
- Mac OS X 雪豹 (10.6.2)
- Apache2
- PHP 5 作为模块运行
谢谢,
最佳答案
我认为 php 无法获取原始输入流的 header 部分。 (getallheaders()/apache _request_headers() 已经提到了)。
但至少你可以通过 php://input stream 读取原始发布数据。 .
关于php - 将完整请求存储在 PHP 变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1846681/