note 21966 added to function.gzcompress

From: Date: Sat, 01 Jun 2002 23:42:27 +0000
Subject: note 21966 added to function.gzcompress
Groups: php.notes 
Request: Send a blank email to php-notes+get-31336@lists.php.net to get a copy of this message
It seems that you don't need anymore to add the crc and the size at the end of the stream, it works fairly with php4.06! I don't have tried for the moment with highest version than php 4.06. The source code: <? function checkCanGzip() { global $HTTP_ACCEPT_ENCODING; if (headers_sent()) return 0; if (strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) return "x-gzip"; if (strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false) return "gzip"; return 0; } function gzDocOut() { if ($encoding = checkCanGzip()) { $contents = ob_get_contents(); ob_end_clean(); header("Content-Encoding: ".$encoding); print("\x1f\x8b\x08\x00\x00\x00\x00\x00"); $size = strlen($contents); $contents = gzcompress($contents, 9); $contents = substr($contents, 0, $size); print($contents); // print(pack('V', crc32($contents))); // print(pack('V', $size)); exit(); } else { ob_end_flush(); exit(); } } ob_start(); ob_implicit_flush(0); print("your stuff..."); gzDocOut(); ?> For the moment, I have only tried on IE5.5, and it works well. Effectively, with the crc and the size at the end of gile, it doesn't work! -- http://www.php.net/manual/en/function.gzcompress.php http://master.php.net/manage/user-notes.php?action=edit+21966 http://master.php.net/manage/user-notes.php?action=delete+21966 http://master.php.net/manage/user-notes.php?action=reject+21966

« previous php.notes (#31336) next »