1--TEST-- 2No router, no script 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6?> 7--FILE-- 8<?php 9include "php_cli_server.inc"; 10php_cli_server_start(NULL, NULL); 11 12$output = ''; 13 14$host = PHP_CLI_SERVER_HOSTNAME; 15$fp = php_cli_server_connect(); 16 17if(fwrite($fp, <<<HEADER 18POST / HTTP/1.1 19Host: {$host} 20Content-Type: application/x-www-form-urlencoded 21Content-Length: 3 22 23a=b 24HEADER 25)) { 26 while (!feof($fp)) { 27 $output .= fgets($fp); 28 } 29} 30 31echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 32fclose($fp); 33 34 35$output = ''; 36$fp = php_cli_server_connect(); 37 38if(fwrite($fp, <<<HEADER 39GET /main/style.css HTTP/1.1 40Host: {$host} 41 42 43HEADER 44)) { 45 while (!feof($fp)) { 46 $output .= fgets($fp); 47 } 48} 49 50echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 51fclose($fp); 52 53$output = ''; 54$fp = php_cli_server_connect(); 55 56if(fwrite($fp, <<<HEADER 57HEAD /main/foo/bar HTTP/1.1 58Host: {$host} 59 60 61HEADER 62)) { 63 while (!feof($fp)) { 64 $output .= fgets($fp); 65 } 66} 67 68echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 69fclose($fp); 70 71$output = ''; 72$fp = php_cli_server_connect(); 73 74if(fwrite($fp, <<<HEADER 75DELETE / HTTP/1.1 76Host: {$host} 77 78 79HEADER 80)) { 81 while (!feof($fp)) { 82 $output .= fgets($fp); 83 } 84} 85 86echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 87fclose($fp); 88 89$output = ''; 90$fp = php_cli_server_connect(); 91 92if(fwrite($fp, <<<HEADER 93PUT / HTTP/1.1 94Host: {$host} 95 96 97HEADER 98)) { 99 while (!feof($fp)) { 100 $output .= fgets($fp); 101 } 102} 103 104echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 105fclose($fp); 106 107$output = ''; 108$fp = php_cli_server_connect(); 109 110if(fwrite($fp, <<<HEADER 111PATCH / HTTP/1.1 112Host: {$host} 113 114 115HEADER 116)) { 117 while (!feof($fp)) { 118 $output .= fgets($fp); 119 } 120} 121 122echo preg_replace("/<style>(.*?)<\/style>/s", "<style>AAA</style>", $output), "\n"; 123fclose($fp); 124?> 125--EXPECTF-- 126HTTP/1.1 404 Not Found 127Host: %s 128Date: %s 129Connection: close 130X-Powered-By: PHP/%s 131Content-Type: text/html; charset=UTF-8 132Content-Length: %d 133 134<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 135</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html> 136HTTP/1.1 404 Not Found 137Host: %s 138Date: %s 139Connection: close 140X-Powered-By: PHP/%s 141Content-Type: text/html; charset=UTF-8 142Content-Length: %d 143 144<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 145</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/style.css</code> was not found on this server.</p></body></html> 146HTTP/1.1 404 Not Found 147Host: %s 148Date: %s 149Connection: close 150X-Powered-By: PHP/%s 151Content-Type: text/html; charset=UTF-8 152Content-Length: %d 153 154 155HTTP/1.1 405 Method Not Allowed 156Host: %s 157Date: %s 158Connection: close 159X-Powered-By: PHP/%s 160Content-Type: text/html; charset=UTF-8 161Content-Length: %d 162Allow: GET, HEAD, POST 163 164<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style> 165</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html> 166HTTP/1.1 405 Method Not Allowed 167Host: %s 168Date: %s 169Connection: close 170X-Powered-By: PHP/%s 171Content-Type: text/html; charset=UTF-8 172Content-Length: %d 173Allow: GET, HEAD, POST 174 175<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style> 176</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html> 177HTTP/1.1 405 Method Not Allowed 178Host: %s 179Date: %s 180Connection: close 181X-Powered-By: PHP/%s 182Content-Type: text/html; charset=UTF-8 183Content-Length: %d 184Allow: GET, HEAD, POST 185 186<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style> 187</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html> 188