1

I'm trying to access the raw HTTP request sent to the server in PHP.

However, all the input/output streams are not working.

I can't use php://input, and I don't want to have to "interpolate" the request from the arrays such as $_COOKIES, $_POST, etc. $_POST, $_GET and the other arrays are working fine. I'm using WAMPServer on Windows 7.

Can anyone help me fix the problem with the input/output streams or find another way to get the raw request data?

6
  • If php://input doesn't work, I doubt that other options will work. Commented Apr 27, 2012 at 12:39
  • 2
    They don't exist. They're treated like files that don't exist. For example, file_exists("php://input") returns false. Commented Apr 27, 2012 at 12:40
  • 1
    Also, possible duplicate of stackoverflow.com/questions/5463596/… Commented Apr 27, 2012 at 12:40
  • Please consult the PHP Manual, there are limitations with php://input, it's not always available, see here: php.net/manual/wrappers.php.php - If you need it for the cases it's documented it is not available, please update your question accordingly so that we can tell you how to re-compile PHP w/o such limitations. Commented Apr 27, 2012 at 12:47
  • @zerkms probably because the content type of the request is multipart/form-data and he didn't read the documentation properly... Commented Apr 27, 2012 at 12:47

1 Answer 1

0

From the PHP docs:

php://input is a read-only stream that allows you to read raw data from the request body

which means you can only read body data, not headers or the raw request. If you're running under Apache, you can use the function apache_request_headers to get all the headers. To get the "request" line (the first line of the request), I suppose you need to concat the strings you can get from the $_SERVER variable.

Sign up to request clarification or add additional context in comments.

2 Comments

For If you're running under Apache read if you're running as an Apache module. It doesn't work in CGI mode. However it does work when running as FastCGI, or as an NSAPI module.
Really? So there isn't a way to get the raw request?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.