1--TEST--
2Bug #60180 ($_SERVER["PHP_SELF"] incorrect)
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', TRUE);
11
12list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
13$port = intval($port)?:80;
14
15$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
16if (!$fp) {
17  die("connect failed");
18}
19
20if(fwrite($fp, <<<HEADER
21GET /foo/bar?foo=bar HTTP/1.1
22Host: {$host}
23
24
25HEADER
26)) {
27	while (!feof($fp)) {
28		echo fgets($fp);
29	}
30}
31
32fclose($fp);
33
34$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
35if (!$fp) {
36  die("connect failed");
37}
38
39
40if(fwrite($fp, <<<HEADER
41GET /index.php/foo/bar/?foo=bar HTTP/1.0
42Host: {$host}
43
44
45HEADER
46)) {
47	while (!feof($fp)) {
48		echo fgets($fp);
49	}
50}
51
52fclose($fp);
53
54?>
55--EXPECTF--
56HTTP/1.1 200 OK
57Host: %s
58Connection: close
59X-Powered-By: PHP/%s
60Content-type: text/html
61
62string(18) "/index.php/foo/bar"
63string(10) "/index.php"
64string(8) "/foo/bar"
65string(7) "foo=bar"
66HTTP/1.0 200 OK
67Host: %s
68Connection: close
69X-Powered-By: PHP/%s
70Content-type: text/html
71
72string(19) "/index.php/foo/bar/"
73string(10) "/index.php"
74string(9) "/foo/bar/"
75string(7) "foo=bar"
76