diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 5a887bd1e1e04..f60f8b21caa64 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1258,13 +1258,13 @@ int make_http_soap_request(zval *this_ptr, if ((strcmp(content_encoding,"gzip") == 0 || strcmp(content_encoding,"x-gzip") == 0) && - zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) { - ZVAL_STRING(&func, "gzinflate"); - ZVAL_STRINGL(¶ms[0], http_body->val+10, http_body->len-10); - } else if (strcmp(content_encoding,"deflate") == 0 && - zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) { + zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) { ZVAL_STRING(&func, "gzuncompress"); ZVAL_STR_COPY(¶ms[0], http_body); + } else if (strcmp(content_encoding,"deflate") == 0 && + zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) { + ZVAL_STRING(&func, "gzinflate"); + ZVAL_STR_COPY(¶ms[0], http_body); } else { efree(content_encoding); zend_string_release_ex(http_headers, 0); diff --git a/ext/soap/tests/bugs/bug47925.phpt b/ext/soap/tests/bugs/bug47925.phpt new file mode 100644 index 0000000000000..ce14c7f46765d --- /dev/null +++ b/ext/soap/tests/bugs/bug47925.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #47925 (PHPClient can't decompress response (transposed uncompress methods?)) +--EXTENSIONS-- +soap +zlib +--SKIPIF-- + +--FILE-- + + + + + 7 + + + +XML; + +function test($compressed_response, $compression_name) { + $length = strlen($compressed_response); + $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"); + ['pid' => $pid, 'uri' => $uri] = http_server([$server_response]); + $client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]); + var_dump($client->Add(3, 4)); + http_server_kill($pid); +} + +test(gzcompress($plain_response), "gzip"); +test(gzdeflate($plain_response), "deflate"); +?> +--EXPECT-- +int(7) +int(7)