Bug #52926 [Ana->Csd]: stream_context_set_default() does not work as intended with stream chaining
Edit report at http://bugs.php.net/bug.php?id=52926&edit=1
ID: 52926
Updated by: pajoye@php.net
Reported by: simast at gmail dot com
Summary: stream_context_set_default() does not work as
intended with stream chaining
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Zlib Related
Operating System: Windows
PHP Version: 5.3.3
-Assigned To:
+Assigned To: pajoye
Block user comment: N
New Comment:
This bug has been fixed in SVN.
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:
------------------------------------------------------------------------
[2010-09-26 22:46:56] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=303772
Log: - fix bug #52926, zlib fopen wrapper does not use the context
------------------------------------------------------------------------
[2010-09-26 22:34:24] simast at gmail dot com
That was quick! I imagine this patch will fix the following code as
well?
file_get_contents(
'compress.zlib://http://example.com',
false,
stream_context_create(array('http' => ...))
);
Thanks!
------------------------------------------------------------------------
[2010-09-26 21:49:12] cataphract@php.net
The following patch has been added/updated:
Patch Name: zlib_inner_open
Revision: 1285530552
URL:
http://bugs.php.net/patch-display.php?bug=52926&patch=zlib_inner_open&revision=1285530552
------------------------------------------------------------------------
[2010-09-26 21:48:49] cataphract@php.net
Fixed in attached patch.
The problem is php_stream_gzopen doesn't forward the context when
opening the inner stream; this isn't limited to default contexts.
------------------------------------------------------------------------
[2010-09-26 15:07:20] simast at gmail dot com
Description:
------------
Hello!
I was trying to add gzip/deflate support to standard HTTP streams (code
attached).
It seems stream_context_set_default() works fine as long as stream
wrappers are
not chained, like when used with "compress.zlib://" it will not use
options as set
with this function and will revert to php default ones.
Simas
Test script:
---------------
stream_context_set_default(array(
'http' => array(
'protocol_version' => 1.1, // HTTP 1.1 compatible
'header' => array(
'Connection: close', // No Keep-Alive
'Accept-Encoding: gzip, deflate' // We support content compression
)
)
));
file_get_contents('compress.zlib://http://example.com');
Expected result:
----------------
Default stream options should be used for chained streams as well.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52926&edit=1
Thread (5 messages)