xref: /PHP-8.3/ext/soap/tests/bugs/bug76232.phpt (revision 1b1677a8)
1--TEST--
2Bug #76232 (SoapClient Cookie Header Semicolon)
3--EXTENSIONS--
4soap
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
14include __DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc";
15
16$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "soap." . PHP_SHLIB_SUFFIX];
17if (php_ini_loaded_file()) {
18  // Necessary such that it works from a development directory in which case extension_dir might not be the real extension dir
19  $args[] = "-c";
20  $args[] = php_ini_loaded_file();
21}
22$code = <<<'PHP'
23/* Receive */
24$content = trim(file_get_contents("php://input")) . PHP_EOL;
25PHP;
26
27php_cli_server_start($code, null, $args);
28
29$client = new soapclient(NULL, [
30  'location' => 'http://' . PHP_CLI_SERVER_ADDRESS,
31  'uri' => 'misc-uri',
32  'trace' => true,
33]);
34
35echo "=== Request with one cookie ===\n";
36
37$client->__setCookie('testcookie1', 'true');
38$client->__soapCall("foo", []);
39echo $client->__getLastRequestHeaders();
40
41echo "=== Request with two cookies ===\n";
42
43$client->__setCookie('testcookie2', 'true');
44$client->__soapCall("foo", []);
45
46echo $client->__getLastRequestHeaders();
47?>
48--EXPECTF--
49=== Request with one cookie ===
50POST / HTTP/1.1
51Host: %s
52Connection: Keep-Alive
53User-Agent: PHP-SOAP/%s
54Content-Type: text/xml; charset=utf-8
55SOAPAction: "misc-uri#foo"
56Content-Length: %d
57Cookie: testcookie1=true
58
59=== Request with two cookies ===
60POST / HTTP/1.1
61Host: %s
62Connection: Keep-Alive
63User-Agent: PHP-SOAP/%s
64Content-Type: text/xml; charset=utf-8
65SOAPAction: "misc-uri#foo"
66Content-Length: %d
67Cookie: testcookie1=true; testcookie2=true
68