php.net |  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
Votes:2
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
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 http://myhost.com/zlib-test.php
> GET /zlib-test.php HTTP/1.1
> Host: myhost.com
> 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:
---------------
<?php
ini_set("zlib.output_compression", 4096);
header("HTTP/1.1 304 Not Modified");


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-11 14:50 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2017-10-11 14:50 UTC] cmb@php.net
Workaround: set Content-Length:0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC