Bug #75150 [Opn->Ver]: zlib.output_compression outputs gzipped data for empty response
| From: | cmb@php.net | Date: | Wed, 11 Oct 2017 14:50:14 +0000 |
| Subject: | Bug #75150 [Opn->Ver]: zlib.output_compression outputs gzipped data for empty response | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211627@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75150&edit=1
ID: 75150
Updated by: cmb@php.net
Reported by: alex dot ryabov at gmail dot com
Summary: zlib.output_compression outputs gzipped data for
empty response
-Status: Open
+Status: Verified
Type: Bug
Package: Zlib related
Operating System: Ubuntu 14.04
PHP Version: 7.0.23
Block user comment: N
Private report: N
New Comment:
Workaround: set Content-Length:0
Previous Comments:
------------------------------------------------------------------------
[2017-09-02 13:54:42] 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");
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75150&edit=1