From: mplomer at gmx dot de
Operating system: any
PHP version: 5.2.5
PHP Bug Type: Zlib Related
Bug description: Clear "Content-Length" HTTP header when
zlib.output_compression active
Description:
------------
If you have a big project, where "Content-Length" header is set on many
places, and then you turn on "zlib.output_compression", you will have a
problem, because the original header is still passed through, but it is
invalid now, because it contains the length of the uncompressed data
instead of the compressed data.
This would confuse some HTTP clients, that rely on the "Content-Length".
I think, "zlib.output_compression" should be completely transparent, so
this issue should be handled in php core.
One solution is, to remove the "Content-Length" header (if set) in
ob_gzhandler() in ext/zlib/zlib.c:882 (where "Content-Encoding: gzip"
header is set). If you see a good way to set the Content-Length to the
compressed length, this would be, of course, the best solution, but this is
IMHO only possible, if the entire data is buffered before (or is this done
by ob_gzhandler anyway?).
This would make the various workarounds irrelevant that have to be done if
"zlib.output_compression" is active and is completely backward compatible.
Reproduce code:
---------------
In php.ini:
zlib.output_compression = On
<?php
$output = str_repeat('A', 8192);
header('Content-Length: ' . strlen($output));
?>
Expected result:
----------------
Correct "Content-Length" header or removed "Content-Length" header in
response, because the old length is always wrong. Better send no
"Content-Length" instead a wrong length.
Actual result:
--------------
The old "Content-Length" header is sent.
--
Edit bug report at http://bugs.php.net/?id=44164&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44164&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44164&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44164&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44164&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44164&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44164&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44164&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44164&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44164&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44164&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44164&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44164&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44164&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44164&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44164&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44164&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44164&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44164&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44164&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44164&r=mysqlcfg