note 60392 deleted from function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 19:37:53 +0000 |
| Subject: | note 60392 deleted from function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142305@lists.php.net to get a copy of this message | ||
Note Submitter: davem
----
For data returned as "chunked" you cannot simply loop through the file with fgets and
return a correct response.
This function has worked for me, any improvements welcome:
//parse response text out of chunked response
function ParseChunked($response)
{
$response = explode("\r\n",$response);
for($i=0; $i<count($response); $i++)
if(hexdec($response[$i])==strlen($response[$i+1]))
$return.=$response[++$i];
return $return;
}