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--EXPECTF-- 72HTTP/1.1 404 Not Found 73Host: %s 74Date: %s 75Connection: close 76Content-Type: text/html; charset=UTF-8 77Content-Length: %d 78 79<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 80</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html> 81HTTP/1.1 404 Not Found 82Host: %s 83Date: %s 84Connection: close 85Content-Type: text/html; charset=UTF-8 86Content-Length: %d 87 88<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 89</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> 90HTTP/1.1 404 Not Found 91Host: %s 92Date: %s 93Connection: close 94Content-Type: text/html; charset=UTF-8 95Content-Length: %d 96 97<!doctype html><html><head><title>404 Not Found</title><style>AAA</style> 98</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/foo/bar</code> was not found on this server.</p></body></html> 99