Bug #75150 [NEW]: zlib.output_compression outputs gzipped data for empty response
From: alex dot ryabov at gmail dot com
Operating system: Ubuntu 14.04
PHP version: 7.0.23
Package: Zlib related
Bug Type: Bug
Bug description:zlib.output_compression outputs gzipped data for empty response
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 bug report at https://bugs.php.net/bug.php?id=75150&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75150&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75150&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75150&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75150&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75150&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75150&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75150&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75150&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75150&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75150&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75150&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75150&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75150&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75150&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75150&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75150&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75150&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75150&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75150&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75150&r=mysqlcfg
Thread (2 messages)
- alex dot ryabov at gmail dot com