|
| 1 | +--TEST-- |
| 2 | +SOAP client follows a redirect with a relative Location resolved against the request path |
| 3 | +--EXTENSIONS-- |
| 4 | +soap |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | +if (!file_exists(__DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc")) { |
| 8 | + echo "skip sapi/cli/tests/php_cli_server.inc required but not found"; |
| 9 | +} |
| 10 | +?> |
| 11 | +--FILE-- |
| 12 | +<?php |
| 13 | +include __DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc"; |
| 14 | + |
| 15 | +$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "soap." . PHP_SHLIB_SUFFIX]; |
| 16 | +if (php_ini_loaded_file()) { |
| 17 | + $args[] = "-c"; |
| 18 | + $args[] = php_ini_loaded_file(); |
| 19 | +} |
| 20 | + |
| 21 | +$code = <<<'PHP' |
| 22 | +if ($_SERVER["REQUEST_URI"] === "/svc/redirected") { |
| 23 | + header("Content-Type: text/xml; charset=utf-8"); |
| 24 | + echo '<?xml version="1.0" encoding="UTF-8"?>', |
| 25 | + '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">', |
| 26 | + '<SOAP-ENV:Body><fooResponse><result>ok</result></fooResponse></SOAP-ENV:Body>', |
| 27 | + '</SOAP-ENV:Envelope>'; |
| 28 | +} else { |
| 29 | + http_response_code(302); |
| 30 | + header("Location: redirected"); |
| 31 | +} |
| 32 | +PHP; |
| 33 | + |
| 34 | +php_cli_server_start($code, null, $args); |
| 35 | + |
| 36 | +$client = new SoapClient(null, [ |
| 37 | + 'location' => 'http://' . PHP_CLI_SERVER_ADDRESS . '/svc/start', |
| 38 | + 'uri' => 'test-uri', |
| 39 | +]); |
| 40 | + |
| 41 | +try { |
| 42 | + $client->__soapCall("foo", []); |
| 43 | + echo "redirect followed\n"; |
| 44 | +} catch (SoapFault $e) { |
| 45 | + echo "SoapFault: " . $e->getMessage() . "\n"; |
| 46 | +} |
| 47 | +?> |
| 48 | +--EXPECT-- |
| 49 | +redirect followed |
0 commit comments