note 60392 added to function.fsockopen
| From: | davem at osu1 dot php dot net | Date: | Thu, 05 Jan 2006 17:25:46 +0000 |
| Subject: | note 60392 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101257@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60392
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60392&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60392&report=yes
Search -- http://master.php.net/manage/user-notes.php