I am writing a service to receive data from an energy monitoring device in my house. The only way the device can push data is by using an HTTP POST
, with Transfer-Encoding: chunked
, and no Content-Length
, and the data as XML in the request body.
I would like to be able to read this data in a PHP script (behind Apache) and store it in my database.
It appears that the most correct way to read the HTTP request body in PHP these days is to open and read php://input
. However, comments from users on PHP's website indicate (and my testing confirms), that if no Content-Length
header is specified by the client, php://input
returns no data (even if there is data being sent by the client in chunked encoding).
Is there an alternate way to get access to the request body? Can I configure Apache (with .htaccess) to decode the chunked data and call my script once it gets it all, and include Content-Length
? Or configure PHP so it will be able to handle this?
Thanks!