note 93436 deleted from function.gzinflate by danbrown

From: Date: Thu, 10 Sep 2009 00:13:47 +0000
Subject: note 93436 deleted from function.gzinflate by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160385@lists.php.net to get a copy of this message
Note Submitter: vitall at ua dot fm ---- The correct function for gzip and chunked data particularly when you get "Content-Encoding: gzip" and "Transfer-Encoding: chunked" headers: function decode_gzip($h,$d,$rn="\r\n"){ if (isset($h['Transfer-Encoding'])){ $lrn = strlen($rn); $str = ''; $ofs=0; do{ $p = strpos($d,$rn,$ofs); $len = hexdec(substr($d,$ofs,$p-$ofs)); $str .= substr($d,$p+$lrn,$len); $ofs = $p+$lrn*2+$len; }while ($d[$ofs]!=='0'); $d=$str; } if (isset($h['Content-Encoding'])) $d = gzinflate(substr($d,10)); return $d; } Enjoy!

« previous php.notes (#160385) next »