I am using PHP5 on Windows 2003 Server.

I have an application where a client sends custom MIME Headers in the request body of an HTTP POST to a page on my webserver (ie: www.example.com/readPOSTBody.php).

I need to know how to access the body of the POST. I don't need the post variables. I don't need anything in $SERVER, $GET,$POST,$ENV,$_REQUEST. I have checked all of them. I either need access to the raw HTTP POST request or just access to the text of the body of the HTTP message.

The actual POST would look like this:

POST / HTTP/1.1
Host: demo.example.com
User-Agent: httpclient 
Content-Type: Text/plain<CR>
Content-Length: 167659<CR>
<CR>
Transaction-ID: 123444
Message-Type: SomeType
Version: 1.0
To: you@mail.com<CR>
<CR>
Message content.

And I need access to the info like "Transaction-ID", "Message-Type","Version", etc ...

Does PHP have any function or variable that I can get this from?

Thank you.

    Hmm... perhaps try this?

    $post_data = file_get_contents('php://input');

    EDIT: If you have the HTTP module installed, mabe use something like this: [man]http_get_request_body/man ?

      Bear in mind that you should NEVER trust the mimetype supplied by the client. It can easily be forged, allowing a malicious user to upload executable code to your server.

        bradgrafelman,
        you are a man among men!!! Thank you!! Thank you!! Thank you!! Thank you!!

        greenie2600,
        Thank you for your input as well. This will be a secure interface that is not exposed to the internet...but even then...I am putting SSL and authentication on it.

        Thank you both!!

          Erm... you're welcome? Heh...

          Anyway, don't forget to mark this thread resolved (it sure sounds like it has been resolved, anyway...).

            Write a Reply...