Bug #47021 [Com]: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked"

From: Date: Thu, 10 Mar 2016 17:17:14 +0000
Subject: Bug #47021 [Com]: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199742@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47021&edit=1 ID: 47021 Comment by: rowan dot collins at gmail dot com Reported by: daniel dot gorski at develnet dot org Summary: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked" Status: Open 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: 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); Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2010-03-03 12:26:58] pcdinh at gmail dot com Have you tried to recompile PHP with --without-curlwrapper? I solved my case. ------------------------------------------------------------------------ [2009-05-17 05:18:55] shadda at gmail dot com I ran into this bug today myself, and after having compiled the latest snapshot as of 8:00pm CST 2009-05-16 I am still experiencing this error. ------------------------------------------------------------------------ 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

« previous php.bugs (#199742) next »