Edit report at https://bugs.php.net/bug.php?id=47021&edit=1
ID: 47021
Updated by: mbeccati@php.net
Reported by: daniel dot gorski at develnet dot org
Summary: SoapClient stumbles over WSDL delivered with
"Transfer-Encoding: chunked"
-Status: Open
+Status: Closed
Type: Bug
Package: SOAP related
Operating System: Linux
PHP Version: 5.3CVS-2009-01-06 (CVS)
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of mbeccati
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f7c43b8c72822a4722bd7404c6f65e15b2b912c1
Log: Fix #47021: SoapClient stumbles over WSDL delivered with "Transfer-Encoding:
chunked"
Previous Comments:
------------------------------------------------------------------------
[2016-05-09 21:06:08] rowan dot collins at gmail dot com
I have submitted a Pull Request to make this detection handle any number of spaces in the HTTP
header: https://github.com/php/php-src/pull/1902
Hopefully this will fix remaining instances of this bug.
------------------------------------------------------------------------
[2016-03-10 17:17:12] rowan dot collins at gmail dot com
To test using the built-in web server:
# create file header-test.php
<?php
$spaces = str_repeat(' ', $_GET['s']);
header("Transfer-Encoding:{$spaces}Chunked");
echo "5\nHello\n0\n";
# Run server
php -S localhost:8080 header-test.php &
# Compare output with 1 vs 2 spaces
$http_1_1_ctx = stream_context_create(["http" => ["protocol_version" =>
"1.1", "header" => "Connection: Close"]]);
// Reports 'Hello', hides Transfer-Encoding header:
file_get_contents('http://localhost:8080/?s=1', false,
$http_1_1_ctx);
var_dump($http_response_header);
// Reports raw chunk data, shows Transfer-Encoding header:
file_get_contents('http://localhost:8080/?s=2', false,
$http_1_1_ctx);
var_dump($http_response_header);
------------------------------------------------------------------------
[2016-03-10 17:07:48] rowan dot collins at gmail dot com
After much head-scratching, I found the bug in the auto-decoding, which is actually independent of
the SOAP wrapping, and occurs here: http://lxr.php.net/xref/PHP_MASTER/ext/standard/http_fopen_wrapper.c#774
The check looks for the exact line "Transfer-Encoding: chunked", but the number of spaces
after the colon is arbitrary; thus any implementation that returns "Transfer-Encoding:
chunked" will not activate the "dechunk" filter.
You can reproduce this by pointing at an offending server with any stream wrapped function and
enabling HTTP/1.1 (which is the default for SOAPClient, but not elsewhere):
<?php
$http_1_1_ctx = stream_context_create(["http" => ["protocol_version" =>
"1.1", "header" => "Connection: Close"]]);
file_get_contents($url, false, $http_1_1_ctx);
var_dump($http_response_header);
------------------------------------------------------------------------
[2012-05-16 15:45:07] gbaudoin at gmail dot com
Workaround : Use a stream context specifying the protocol 1.0 of HTTP :
$opts = array('http' => array('protocol_version' => '1.0'));
$context = stream_context_create($opts);
$this->client = new SoapClient($wsdl, array('stream_context' => $context));
------------------------------------------------------------------------
[2010-08-17 19:14:28] n dot engyozov at taxundo dot com
I can confirm the problem is still present in my PHP version 5.3.3 even after recompiling with
changes made by Dmitry and with disabled curlwrapper. The problem breaks wsdls from yahoo i google
APIs.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=47021
--
Edit this bug report at https://bugs.php.net/bug.php?id=47021&edit=1