bug47021.phpt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. Bug #47021 SoapClient (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked")
  3. --INI--
  4. soap.wsdl_cache_enabled=0
  5. --EXTENSIONS--
  6. soap
  7. --SKIPIF--
  8. <?php
  9. require __DIR__.'/../../standard/tests/http/server.inc';
  10. http_server_skipif();
  11. --FILE--
  12. <?php
  13. require __DIR__.'/../../standard/tests/http/server.inc';
  14. function chunk_body($body, $n)
  15. {
  16. $chunks = str_split($body, $n);
  17. $chunks[] = '';
  18. foreach ($chunks as $k => $v) {
  19. $chunks[$k] = sprintf("%08x\r\n%s\r\n", strlen($v), $v);
  20. }
  21. return join('', $chunks);
  22. }
  23. $wsdl = file_get_contents(__DIR__.'/server030.wsdl');
  24. $soap = <<<EOF
  25. <?xml version="1.0" encoding="UTF-8"?>
  26. <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>
  27. EOF;
  28. $responses = [
  29. "data://text/plain,HTTP/1.1 200 OK\r\n".
  30. "Content-Type: text/xml;charset=utf-8\r\n".
  31. "Transfer-Encoding: \t chunked\t \r\n".
  32. "Connection: close\r\n".
  33. "\r\n".
  34. chunk_body($wsdl, 64),
  35. "data://text/plain,HTTP/1.1 200 OK\r\n".
  36. "Content-Type: text/xml;charset=utf-8\r\n".
  37. "Transfer-Encoding: \t chunked\t \r\n".
  38. "Connection: close\r\n".
  39. "\r\n".
  40. chunk_body($soap, 156),
  41. ];
  42. ['pid' => $pid, 'uri' => $uri] = http_server($responses);
  43. $options = [
  44. 'trace' => true,
  45. 'location' => $uri,
  46. ];
  47. class BugSoapClient extends SoapClient
  48. {
  49. public function __doRequest($request, $location, $action, $version, $one_way = null): ?string
  50. {
  51. $response = parent::__doRequest($request, $location, $action, $version, $one_way);
  52. var_dump(strlen($response));
  53. return $response;
  54. }
  55. }
  56. $client = new BugSoapClient($uri, $options);
  57. var_dump(count($client->getItems()));
  58. http_server_kill($pid);
  59. --EXPECT--
  60. int(1291)
  61. int(10)