note 29824 added to function.gzcompress

From: Date: Wed, 26 Feb 2003 09:26:24 +0000
Subject: note 29824 added to function.gzcompress
Groups: php.notes 
Request: Send a blank email to php-notes+get-44540@lists.php.net to get a copy of this message
It seems that you don't have to pack the crc-checksum and the length of the string. The crucial thing is to erase the last 4 bytes of the gzcompressed content. They seem to be redundant in any case. I rewrote the function "gzDocOut" and I think, it is the most efficient and shortest way to encode an output with gzcompress: function gzDocOut() { if ($encoding = checkCanGzip()) { $contents = ob_get_contents(); ob_end_clean(); header("Content-Encoding: ". $encoding); $output = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; $output .= substr(gzcompress($contents, 2), 0, -4); echo $output; exit(); } else { ob_end_flush(); exit(); } } Tested with IE5.5, Netscape 7, Mozilla 1.2, Opera 7, Opera 6 as well as Netscape 4.7. I'll test further browsers to be sure... -- http://www.php.net/manual/en/function.gzcompress.php http://master.php.net/manage/user-notes.php?action=edit+29824 http://master.php.net/manage/user-notes.php?action=delete+29824 http://master.php.net/manage/user-notes.php?action=reject+29824

« previous php.notes (#44540) next »