note 75175 added to function.fsockopen
| From: | martjean77 at hot dot sapm dot mail dot com | Date: | Wed, 16 May 2007 14:44:51 +0000 |
| Subject: | note 75175 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126643@lists.php.net to get a copy of this message | ||
Just a correction
The function decode_jbr at ya-right dot com work nice for me (thanks), but is missing a last case,
for when the response is not chunked (because it's too short for exemple), here a corrected
function :
function decode_body ( $info, $str, $eol = "\r\n" )
{
$tmp = $str;
$add = strlen ( $eol );
$str = '';
if ( isset ( $info['transfer-encoding'] ) &&
$info['transfer-encoding'] == 'chunked' )
{
do
{
$tmp = ltrim ( $tmp );
$pos = strpos ( $tmp, $eol );
$len = hexdec ( substr ( $tmp, 0, $pos ) );
if ( isset ( $info['content-encoding'] ) )
{
$str .= gzinflate ( substr ( $tmp, ( $pos + $add + 10 ), $len ) );
}
else
{
$str .= substr ( $tmp, ( $pos + $add ), $len );
}
$tmp = substr ( $tmp, ( $len + $pos + $add ) );
$check = trim ( $tmp );
}
while ( ! empty ( $check ) );
}
else if ( isset ( $info['content-encoding'] ) )
{
$str = gzinflate ( substr ( $tmp, 10 ) );
}
else {
$str = $tmp;
}
return $str;
}
----
Server IP: 194.153.94.10
Probable Submitter: 213.221.154.157
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- https://master.php.net/note/edit/75175
Del: integrated -- https://master.php.net/note/delete/75175/integrated
Del: useless -- https://master.php.net/note/delete/75175/useless
Del: bad code -- https://master.php.net/note/delete/75175/bad+code
Del: spam -- https://master.php.net/note/delete/75175/spam
Del: non-english -- https://master.php.net/note/delete/75175/non-english
Del: in docs -- https://master.php.net/note/delete/75175/in+docs
Del: other reasons-- https://master.php.net/note/delete/75175
Reject -- https://master.php.net/note/reject/75175
Search -- https://master.php.net/manage/user-notes.php