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"]);', null);
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
58Date: %s
59Connection: close
60X-Powered-By: PHP/%s
61Content-type: text/html; charset=UTF-8
62
63string(18) "/index.php/foo/bar"
64string(10) "/index.php"
65string(8) "/foo/bar"
66string(7) "foo=bar"
67HTTP/1.0 200 OK
68Host: %s
69Date: %s
70Connection: close
71X-Powered-By: PHP/%s
72Content-type: text/html; charset=UTF-8
73
74string(19) "/index.php/foo/bar/"
75string(10) "/index.php"
76string(9) "/foo/bar/"
77string(7) "foo=bar"
78