Re: Problems with output buffering and gzcompress()
| From: | Chris Lee | Date: | Fri, 05 Jan 2001 03:59:48 +0000 |
| Subject: | Re: Problems with output buffering and gzcompress() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32814@lists.php.net to get a copy of this message | ||
Ok, Ive got it, so heres the deal
<?
function compress_output($output)
{
$crc = pack('V',crc32($output));
$size = pack('V',strlen($output));
$output = gzcompress($output, 9);
$data = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$data .= substr($output, 0, strlen($output) - 4);
$data .= $crc;
$data .= $size;
return $data;
}
header("Content-Encoding: gzip");
ob_start("compress_output");
echo "hi there this works eh";
?>
this seems to work in all browsers Ive tested,
Netscape 6
Opera 5.0.1
IE 5.5
Amaya 4.2.1
does anyone know what the header for bzip is ? has anyone got this workign
with bzcompress() ? I would be interested in hearing about it.
Chris Lee
Mediawaveonline.com
""Chris Lee"" <lee@mediawaveonline.com> wrote in message
news:933cp2$qbo$1@toye.p.sourceforge.net...
> heres whats not working, I can get php to compress my output buffer but I
> cant get my function to work in all browsers.
>
>
//--------------------------------------------------------------------------
> ---------
> header("Content-Encoding: gzip");
> ob_start("compress_output");
>
//--------------------------------------------------------------------------
> ---------
>
> echo "hello? what? why do you say it like that?<br>\n";
>
> ok there is the code
>
>
>
>
>
> Opera 5.01 - displays page ok, but gives a "data corrupt error"
> IE 5.5 - displays blank page
> Lynx 2.8.3 - everything works
> Amaya 4.2.1 - everything works
> Netscape 6 - everything works
>
//--------------------------------------------------------------------------
> ---------
> function compress_output($output)
> {
> $output = gzcompress($output);
>
> $size = strlen($output);
> $crc = crc32($output);
>
> $output = substr($output, 0, strlen($output) - 4);
>
> $data = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
> $data .= $output;
> $data .= pack("V",$crc);
> $data .= pack("V",$size);
>
> return $data;
> }
>
//--------------------------------------------------------------------------
> ---------
>
>
>
> Opera 5.01 - GPF's
> IE 5.5 - everything works
> Lynx 2.8.3 - everything works
> Amaya 4.2.1 - everything works
> Netscape 6 - everything works
>
//--------------------------------------------------------------------------
> ---------
> function compress_output($output)
> {
> $output = gzcompress($output);
>
> $size = strlen($output);
> $crc = crc32($output);
>
> $data = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
> $data .= $output;
>
> return $data;
> }
>
//--------------------------------------------------------------------------
> ---------
>
>
>
> Any idea's ? With one IE doesnt work, with the other Opera doesnt work.
>
> And all you who say "no one uses Opera" dont bother saying it. :)
>
>
> Chris Lee
> Mediawaveonline.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>