xref: /php-src/ext/soap/tests/bugs/bug47925.phpt (revision ce7ed6e0)
1--TEST--
2Bug #47925 (PHPClient can't decompress response (transposed uncompress methods?))
3--EXTENSIONS--
4soap
5zlib
6--SKIPIF--
7<?php
8if (@!include __DIR__."/../../../standard/tests/http/server.inc") die('skip server.inc not available');
9http_server_skipif();
10?>
11--FILE--
12<?php
13require __DIR__."/../../../standard/tests/http/server.inc";
14
15$plain_response = <<<XML
16<?xml version="1.0" encoding="UTF-8"?>
17<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" 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/">
18    <SOAP-ENV:Body>
19        <ns1:AddResponse>
20            <return xsi:type="xsd:int">7</return>
21        </ns1:AddResponse>
22    </SOAP-ENV:Body>
23</SOAP-ENV:Envelope>
24XML;
25
26function test($compressed_response, $compression_name) {
27    $length = strlen($compressed_response);
28    $server_response = "data://text/xml;base64," . base64_encode("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Encoding: $compression_name\r\nContent-Length: $length\r\n\r\n$compressed_response");
29    ['pid' => $pid, 'uri' => $uri] = http_server([$server_response]);
30    $client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]);
31    var_dump($client->Add(3, 4));
32    http_server_kill($pid);
33}
34
35test(gzencode($plain_response), "gzip");
36test(gzcompress($plain_response), "deflate");
37?>
38--EXPECT--
39int(7)
40int(7)
41