Reputation:
I'm creating a framework in PHP, and I need to get the complete raw request done by the browser. So I want something like this in a variable:
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
Is this possible?
My server information:
Thanks,
Upvotes: 1
Views: 1319
Reputation: 72530
If you mean the server headers from another web page, then use the get_headers()
function.
If you mean the headers from the user request of the page, you can use the apache_request_headers()
function. Though as kon says, the preferred method is doing this:
<?php $postdata = file_get_contents("php://input"); ?>
You need to make sure you have the always_populate_raw_post_data
option on in your php.ini.
Upvotes: 0
Reputation: 96159
I don't think php can get hold of the headers part of the raw input stream. (getallheaders()/apache _request_headers() has already been mentioned).
But at least you can read the raw post data via the php://input stream.
Upvotes: 2
Reputation: 554
i suppose you have to manually put this together using the $_SERVER vars and the contents of
print_r(getallheaders());
Upvotes: 0