|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75150 zlib.output_compression outputs gzipped data for empty response
Submitted: 2017-09-02 13:54 UTC Modified: 2017-10-11 14:50 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: alex dot ryabov at gmail dot com Assigned:
Status: Verified Package: Zlib related
PHP Version: 7.0.23 OS: Ubuntu 14.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: alex dot ryabov at gmail dot com
New email:
PHP Version: OS:


 [2017-09-02 13:54 UTC] alex dot ryabov at gmail dot com
In case of zlib.output_compression turned on and if the script's only output is HTTP header "304 Not Modified", actual PHP output is 20 bytes of gzipped nothing (ungzipping this data produces empty stream) without "Content-Length" header set.

Example (see zlib-test.php below):

~> curl --compressed -v
> GET /zlib-test.php HTTP/1.1
> Host:
> User-Agent: curl/7.54.0
> Accept: */*
> Accept-Encoding: deflate, gzip
< HTTP/1.1 304 Not Modified
< Date: Sat, 02 Sep 2017 09:54:26 GMT
< Connection: keep-alive
< Vary: Accept-Encoding
* Excess found in a non pipelined read: excess = 20 url = /zlib-test.php (zero-length body)

Excessive 20 bytes could be a problem on client side if keep-alive is used: since Content-Length is unknown, the data will stay in buffer until next request and will be read as the beginning of the response.

The issue persists between PHP version (tested with 7.0.21 and 7.0.23) and regardless of webserver setup (Apache + mod_php or nginx + PHP-FPM).

Test script:
ini_set("zlib.output_compression", 4096);
header("HTTP/1.1 304 Not Modified");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-11 14:50 UTC]
-Status: Open +Status: Verified
 [2017-10-11 14:50 UTC]
Workaround: set Content-Length:0
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 11:01:26 2023 UTC