note 75175 deleted from function.fsockopen by danbrown

From: Date: Sun, 20 Jul 2008 19:31:15 +0000
Subject: note 75175 deleted from function.fsockopen by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142298@lists.php.net to get a copy of this message
Note Submitter: martjean77 at hot dot sapm dot mail dot com ---- [EDIT by danbrown AT php DOT net: The original function has been deleted from the user notes. The author of this note credits the original author.] Just a correction The function by 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 : <?php 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; } ?>

« previous php.notes (#142298) next »