|
| 1 | +--TEST-- |
| 2 | +Bug #47021 SoapClient (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked") |
| 3 | +--INI-- |
| 4 | +soap.wsdl_cache_enabled=0 |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | + |
| 8 | +require 'skipif.inc'; |
| 9 | + |
| 10 | +require __DIR__.'/../../standard/tests/http/server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); |
| 11 | + |
| 12 | +?> |
| 13 | +--FILE-- |
| 14 | +<?php |
| 15 | +require __DIR__.'/../../standard/tests/http/server.inc'; |
| 16 | + |
| 17 | +function chunk_body($body, $n) |
| 18 | +{ |
| 19 | + $chunks = str_split($body, $n); |
| 20 | + $chunks[] = ''; |
| 21 | + |
| 22 | + foreach ($chunks as $k => $v) { |
| 23 | + $chunks[$k] = sprintf("%08x\r\n%s\r\n", strlen($v), $v); |
| 24 | + } |
| 25 | + |
| 26 | + return join('', $chunks); |
| 27 | +} |
| 28 | + |
| 29 | +$wsdl = file_get_contents(__DIR__.'/server030.wsdl'); |
| 30 | + |
| 31 | +$soap = <<<EOF |
| 32 | +<?xml version="1.0" encoding="UTF-8"?> |
| 33 | +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getItemsResponse><getItemsReturn SOAP-ENC:arrayType="ns1:Item[10]" xsi:type="ns1:ItemArray"><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text0</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text1</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text2</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text3</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text4</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text5</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text6</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text7</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text8</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text9</text></item></getItemsReturn></ns1:getItemsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> |
| 34 | +EOF; |
| 35 | + |
| 36 | +$responses = [ |
| 37 | + "data://text/plain,HTTP/1.1 200 OK\r\n". |
| 38 | + "Content-Type: text/xml;charset=utf-8\r\n". |
| 39 | + "Transfer-Encoding: \t chunked\t \r\n". |
| 40 | + "Connection: close\r\n". |
| 41 | + "\r\n". |
| 42 | + chunk_body($wsdl, 64), |
| 43 | + "data://text/plain,HTTP/1.1 200 OK\r\n". |
| 44 | + "Content-Type: text/xml;charset=utf-8\r\n". |
| 45 | + "Transfer-Encoding: \t chunked\t \r\n". |
| 46 | + "Connection: close\r\n". |
| 47 | + "\r\n". |
| 48 | + chunk_body($soap, 156), |
| 49 | +]; |
| 50 | + |
| 51 | + |
| 52 | +$pid = http_server('tcp://127.0.0.1:12342', $responses); |
| 53 | + |
| 54 | +$options = [ |
| 55 | + 'trace' => true, |
| 56 | + 'location' => 'http://127.0.0.1:12342/', |
| 57 | +]; |
| 58 | + |
| 59 | +class BugSoapClient extends SoapClient |
| 60 | +{ |
| 61 | + public function __doRequest($request, $location, $action, $version, $one_way = null) |
| 62 | + { |
| 63 | + $response = parent::__doRequest($request, $location, $action, $version, $one_way); |
| 64 | + |
| 65 | + var_dump(strlen($response)); |
| 66 | + |
| 67 | + return $response; |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +$client = new BugSoapClient('http://127.0.0.1:12342/', $options); |
| 72 | + |
| 73 | +var_dump(count($client->getItems())); |
| 74 | + |
| 75 | +http_server_kill($pid); |
| 76 | + |
| 77 | +?> |
| 78 | +--EXPECT-- |
| 79 | +int(1291) |
| 80 | +int(10) |
0 commit comments