Thanks for the code, but I figured out the issue I was having. My problem was actually getting the data not parsing chunked text. After taking a wireshark trace of the traffic I realised that the chunked xml didn't even hit the php process and instead died somewhere in IIS's fastcgi process. If anyone else stumbles upon this, here is the problem and my solution. Production env was IIS 6.0, php 5.2.9-2, installed as module under fastcgi. XML posted form services was sent to the php script responsible for handling it However, if the xml data was chunked, IIS would die with a "500 Server Error" message and the php processor would never even see the xml. >From what I can gather (really not a whole lot of data out there), fastcgi under IIS 6.0 doesn't seem to handle chunked transfer-encoded data.......(it seems like such a major flaw that I'm wondering if I missed some configuration setting to get it to work?) Solution: Since php5.2.9-2 no longer has the isapi module, I had to uninstall 5.2.9-2 and instead installed 5.2.6 with the php5isapi.dll. Once that was configured I retested and hey presto, the chunked data is sent to the php process without error. I didn't even need to decode the chunked data as it is done before I even get access to the data. Spent a day trying to figure out what was wrong, hopefully it'll save someone else some time. Nathan Rixham wrote: > > Shawn McKenzie wrote: >> whisperstream wrote: >>> I have a server running that receives xml formatted events from other >>> services I have no control over. For certain events the >>> transfer-encoding >>> is chunked. >>> >>> I was just doing >>> >>> $input = file_get_contents('php://stdin'); >>> >>> and this works well until there is chunked input. Then I tried >>> >>> $handle = fopen('php://input', "rb"); >>> $input = ''; >>> while (!feof($handle)) { >>> $input .= fread($handle, 8192); >>> } >>> fclose($handle); >>> >>> And that gives about the same result, has anyone else come across this >>> and >>> how did they solve it? >>> >>> Thanks in advance >>> >> >> There aren't really many examples around, but check >> http_chunked_decode() from PECL. >> > > simples! > > function HTTPChunkDecoder( $chunkedData ) { > $decodedData = ''; > do { > $tempChunk = explode(chr(13).chr(10), $chunkedData, 2); > $chunkSize = hexdec($tempChunk[0]); > $decodedData .= substr($tempChunk[1], 0, $chunkSize); > $chunkedData = substr($tempChunk[1], $chunkSize+2); > } while (strlen($chunkedData) > 0); > return $decodedData; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- View this message in context: http://www.nabble.com/handling-chunked-input-from-php%3A--stdin-tp23512171p23533268.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php