php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32283 zlib.output_compression = 1 but no headers sent
Submitted: 2005-03-12 00:10 UTC Modified: 2009-08-18 14:57 UTC
Votes:7
Avg. Score:4.3 ± 0.9
Reproduced:7 of 7 (100.0%)
Same Version:1 (14.3%)
Same OS:5 (71.4%)
From: plasmahh at gmx dot net Assigned:
Status: Closed Package: Output Control
PHP Version: 5CVS-2005-03-14 OS: Linux
Private report: No CVE-ID: None
 [2005-03-12 00:10 UTC] plasmahh at gmx dot net
Description:
------------
When setting zlib.output_compression in php.ini and outputting any page (tried with <? phpinfo(); ?>) no proper headers are sent. From zlib manual :
 Whether to transparently compress pages. If this option is set to "On" in php.ini or the Apache configuration, pages are compressed if the browser sends an "Accept-Encoding: gzip" or "deflate" header. "Content-Encoding: gzip" (respectively "deflate") and "Vary: Accept-Encoding" headers are added to the output.

It looks like in zlib.c the php_enable_output_compression function should enable the compression, which it also does (the data is sent gzipped properly if the client has a proper Accept-Encoding header sent) but nowhere in there is a header sent with Content-Encoding. The only occurence is in the ob_gzhandler but it seems like this is a totally different feature. I have set a header output in my php_enable_output_compression and it works for me, dont know if this is the proper solution.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-12 14:42 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-03-14 19:45 UTC] plasmahh at gmx dot net
Does not work too with the snapshot... I have changed parts of the php_enable_output_compression as followed, which works around my problem...

        if (php_memnstr(Z_STRVAL_PP(a_encoding), "gzip", 4, Z_STRVAL_PP(a_encoding) + Z_STRLEN_PP(a_encoding))) {
                ZLIBG(compression_coding) = CODING_GZIP;
                sapi_add_header("Content-Encoding: gzip", sizeof("Content-Encoding: gzip") - 1, 1);
        } else if (php_memnstr(Z_STRVAL_PP(a_encoding), "deflate", 7, Z_STRVAL_PP(a_encoding) + Z_STRLEN_PP(a_encoding))) {
                ZLIBG(compression_coding) = CODING_DEFLATE;
                sapi_add_header("Content-Encoding: deflate", sizeof("Content-Encoding: deflate") - 1, 1);
        } else {
                return FAILURE;
        }
 [2005-03-17 18:02 UTC] iliaa@php.net
What headers are being sent by the browser making the request?
 [2005-03-25 15:13 UTC] plasmahh at gmx dot net
This is an example when I do it with mozilla, but its always the same whenever an accept encoding of gzip or deflate is present...

GET / HTTP/1.1

Host: localhost

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050321

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive
 [2005-04-12 08:44 UTC] sniper@php.net
Is ext/zlib compiled as shared by any chance in your system?
What was the configure line you've used?

 [2005-04-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-05-02 16:05 UTC] matt at dis dot com
I have this problem too, albeit with PHP 4.3.7. Very annoying
 [2009-07-29 00:37 UTC] apinstein at mac dot com
I had this same problem when I upgraded an existing install to php 5.3. 
Turns out that the problem is ext/zlib. When I de-activated that module 
it behaved as expected.

Not sure if that means this is a php bug or a ext/zlib bug, but at least 
it's reproducible! Hope that helps someone.

My config (in httpd.conf):
    # enable php gzip
    php_flag zlib.output_compression On
    php_value zlib.output_compression_level 9

One more thing to add, although it "works" when zlib is disabled, there 
is no compression!
 [2009-08-18 14:57 UTC] jani@php.net
This is now fixed in all branches.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 05:05:53 2022 UTC