Re: Update: HTTP_Download

From: Date: Mon, 29 Sep 2003 19:16:48 +0000
Subject: Re: Update: HTTP_Download
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22181@lists.php.net to get a copy of this message
Monday, September 29, 2003, 8:47:54 PM, Michael Wallner wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > Hi, > now, some tests later: > 1) No gzip implemented. > Browsers do weird things if output_handler is ob_gzhandler > or zlib.output_compression is enabled. > IE kinda hangs and Mozilla saves already gzipped files as files > gzipped 2 times including a CRC Error. > Furthermore we would have to read the whole file into memory if > we want to gzip it by ourself. Sorry Tomas (or got any idea?). I just remember an old piece of code that I used for an app. It worked right, well, not entirely because of a bug with IE, HTTPS and compressed contents (I don't know if was solved or not in recent IE versions). Here is it: if (ereg('gzip, deflate', $HTTP_ACCEPT_ENCODING)) { // Generation of Gzipped content header("Content-Encoding: gzip"); echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; ob_start(); readfile($file); $contents = ob_get_contents(); ob_end_clean(); $size = strlen($contents); $crc = crc32($contents); $contents = gzcompress($contents, 9); $contents = substr($contents, 0, strlen($contents) - 4); echo $contents . pack('V', $crc) . pack('V', $size); } else { readfile($file); } -- Tomas V.V.Cox mailto:cox@idecnet.com

« previous php.pear.dev (#22181) next »