#43793 [Opn->Csd]: zlib filter is unable to auto-detect gzip/zlib file headers
| From: | cellog@php.net | Date: | Wed, 09 Jan 2008 07:09:25 +0000 |
| Subject: | #43793 [Opn->Csd]: zlib filter is unable to auto-detect gzip/zlib file headers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121150@lists.php.net to get a copy of this message | ||
ID: 43793
Updated by: cellog@php.net
Reported By: cellog@php.net
-Status: Open
+Status: Closed
Bug Type: Streams related
Operating System: n/a
PHP Version: 5.2.5
Assigned To: cellog
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-01-09 06:38:43] cellog@php.net
Description:
------------
according to the zlib documentation for inflateInit2() in zlib.h
(online copy at
http://www.raspberryginger.com/jbailey/minix/html/zlib_8h-source.html):
windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic
header
detection, or add 16 to decode only the gzip format (the zlib format
will return a Z_DATA_ERROR)
zlib.inflate filter's filterparams only accepts window size of 15, but
should accept up to 15+32 according to these docs.
Reproduce code:
---------------
<?php /* $Id: zlib_filter_inflate.phpt,v 1.1.2.1 2005/11/24 04:37:47
pollita Exp $ */
$a = gzopen(dirname(__FILE__) . '/test.txt.gz', 'w');
fwrite($a, "This is quite the thing ain't it\n");
fclose($a);
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
echo fread($fp, 2000);
fclose($fp);
echo "1\n";
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
// zlib format
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ,
array('window' => 15+16));
echo "2\n";
echo fread($fp, 2000);
fclose($fp);
// auto-detect
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ,
array('window' => 15+32));
echo "3\n";
echo fread($fp, 2000);
fclose($fp);
?>
Expected result:
----------------
1
2
This is quite the thing ain't it
3
This is quite the thing ain't it
Actual result:
--------------
1
2
3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43793&edit=1