|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-07-21 02:48 UTC] jflatnes at vt dot edu
Description:
------------
When the configuration option 'zlib.output_compression' is set to a boolean value, output is compressed and the appropriate HTTP headers are sent. When the option is set to a string like 'true' or 'On', the output is compressed, but no headers are sent, causing browsers to fail to interpret the output as compressed.
Reproduce code:
---------------
<?php
ini_set('zlib.output_compression', 'On');
echo 'hello, world';
?>
Expected result:
----------------
The output "hello, world" to be gzip/deflate compressed as appropriate for Accept-Encoding, and the Content-Encoding and Vary HTTP headers to be set.
Actual result:
--------------
Instead, the output is indeed gzip-compressed, but the Content-Encoding and Vary headers are not set.
The actual text that the browser prints is:
?������?H????Q(?/?I���??�:r??���
Note, this works correctly with the an ini_set argument of the boolean value true. The documentation claims that ini_set should take string arguments, though. Even if a boolean/integer is required to activate output compression, the behavior should either be "all on" or "all off".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 07:00:01 2025 UTC |
Try this too: <?php var_dump(ini_set('zlib.output_compression', 'On')); ?> Also note that using "On" or "Off" or such with ini_set() does NOT work like they do when used in php.ini.<?php var_dump(ini_set('zlib.output_compression', 'On')); ?> Results in: string(0) "" (meaning I had no previous setting for zlib.output_compression, I believe) --- I am coming to understand that the string 'On' doesn't behave the same way in ini_set as in an ini file, as mentioned. The issue I see here is that there are two options for zlib compression: zlib.output_compression = false: no compression with no headers. zlib.output_compression = true: compression with appropriate headers. Passing a string to ini_set (other than the string '1') causes a third, undocumented behavior: zlib.output_compression = 'On': compression without the headers. Those three states describe the behavior I'm seeing, and the third state seems like a bug. If 'On' is an invalid setting, shouldn't the compression simply not be activated? Am I thinking about this correctly?)I ran into this issue today as well... but I have more to add. Using PHP 5.3 + zlib 1.2.3 I *cannot* get compression + headers. I can get no compression, or compression w/o headers, but never "working" compression+headers. I have tried: httpd.conf: php_flag zlib.output_compression On php_admin_flag zlib.output_compression On -> zip + no headers php_flag zlib.output_compression true php_admin_flag zlib.output_compression true -> not zipped In app.php: ini_set('zlib.output_compression', true); ini_set('zlib.output_compression', "On"); -> not zipped