|
| 1 | +--TEST-- |
| 2 | +Bug #60159 (Router returns false, but POST is not passed to requested resource) |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +include "skipif.inc"; |
| 6 | +?> |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | +include "php_cli_server.inc"; |
| 10 | +php_cli_server_start('<?php ?>', true); |
| 11 | +$doc_root = __DIR__; |
| 12 | + |
| 13 | +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); |
| 14 | +$port = intval($port)?:80; |
| 15 | + |
| 16 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 17 | +if (!$fp) { |
| 18 | + die("connect failed"); |
| 19 | +} |
| 20 | + |
| 21 | +file_put_contents($doc_root . '/foo.html', ''); |
| 22 | +if(fwrite($fp, <<<HEADER |
| 23 | +GET /foo.html HTTP/1.1 |
| 24 | +Host: {$host} |
| 25 | +
|
| 26 | +
|
| 27 | +HEADER |
| 28 | +)) { |
| 29 | + while (!feof($fp)) { |
| 30 | + $text = fgets($fp); |
| 31 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 32 | + echo "foo.html => ", $text; |
| 33 | + } |
| 34 | + } |
| 35 | +} |
| 36 | +@unlink($doc_root . '/foo.html'); |
| 37 | +fclose($fp); |
| 38 | + |
| 39 | + |
| 40 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 41 | +if (!$fp) { |
| 42 | + die("connect failed"); |
| 43 | +} |
| 44 | +file_put_contents($doc_root . '/foo.htm', ''); |
| 45 | +if(fwrite($fp, <<<HEADER |
| 46 | +GET /foo.htm HTTP/1.1 |
| 47 | +Host: {$host} |
| 48 | +
|
| 49 | +
|
| 50 | +HEADER |
| 51 | +)) { |
| 52 | + while (!feof($fp)) { |
| 53 | + $text = fgets($fp); |
| 54 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 55 | + echo "foo.htm => ", $text; |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | +@unlink($doc_root . '/foo.htm'); |
| 60 | +fclose($fp); |
| 61 | + |
| 62 | + |
| 63 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 64 | +if (!$fp) { |
| 65 | + die("connect failed"); |
| 66 | +} |
| 67 | +file_put_contents($doc_root . '/foo.svg', ''); |
| 68 | +if(fwrite($fp, <<<HEADER |
| 69 | +GET /foo.svg HTTP/1.1 |
| 70 | +Host: {$host} |
| 71 | +
|
| 72 | +
|
| 73 | +HEADER |
| 74 | +)) { |
| 75 | + while (!feof($fp)) { |
| 76 | + $text = fgets($fp); |
| 77 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 78 | + echo "foo.svg => ", $text; |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +@unlink($doc_root . '/foo.svg'); |
| 83 | +fclose($fp); |
| 84 | + |
| 85 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 86 | +if (!$fp) { |
| 87 | + die("connect failed"); |
| 88 | +} |
| 89 | +file_put_contents($doc_root . '/foo.css', ''); |
| 90 | +if(fwrite($fp, <<<HEADER |
| 91 | +GET /foo.css HTTP/1.1 |
| 92 | +Host: {$host} |
| 93 | +
|
| 94 | +
|
| 95 | +HEADER |
| 96 | +)) { |
| 97 | + while (!feof($fp)) { |
| 98 | + $text = fgets($fp); |
| 99 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 100 | + echo "foo.css => ", $text; |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | +@unlink($doc_root . '/foo.css'); |
| 105 | +fclose($fp); |
| 106 | + |
| 107 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 108 | +if (!$fp) { |
| 109 | + die("connect failed"); |
| 110 | +} |
| 111 | +file_put_contents($doc_root . '/foo.js', ''); |
| 112 | +if(fwrite($fp, <<<HEADER |
| 113 | +GET /foo.js HTTP/1.1 |
| 114 | +Host: {$host} |
| 115 | +
|
| 116 | +
|
| 117 | +HEADER |
| 118 | +)) { |
| 119 | + while (!feof($fp)) { |
| 120 | + $text = fgets($fp); |
| 121 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 122 | + echo "foo.js => ", $text; |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | +@unlink($doc_root . '/foo.js'); |
| 127 | +fclose($fp); |
| 128 | + |
| 129 | +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); |
| 130 | +if (!$fp) { |
| 131 | + die("connect failed"); |
| 132 | +} |
| 133 | +file_put_contents($doc_root . '/foo.png', ''); |
| 134 | +if(fwrite($fp, <<<HEADER |
| 135 | +GET /foo.png HTTP/1.1 |
| 136 | +Host: {$host} |
| 137 | +
|
| 138 | +
|
| 139 | +HEADER |
| 140 | +)) { |
| 141 | + while (!feof($fp)) { |
| 142 | + $text = fgets($fp); |
| 143 | + if (strncasecmp("Content-type:", $text, 13) == 0) { |
| 144 | + echo "foo.png => ", $text; |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | +@unlink($doc_root . '/foo.png'); |
| 149 | +fclose($fp); |
| 150 | +?> |
| 151 | +--EXPECTF-- |
| 152 | +foo.html => Content-Type: text/html; charset=UTF-8 |
| 153 | +foo.htm => Content-Type: text/html; charset=UTF-8 |
| 154 | +foo.svg => Content-Type: image/svg+xml |
| 155 | +foo.css => Content-Type: text/css; charset=UTF-8 |
| 156 | +foo.js => Content-Type: text/javascript; charset=UTF-8 |
| 157 | +foo.png => Content-Type: image/png |
0 commit comments