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
130Content-Type: text/html; charset=UTF-8
131Content-Length: %d
132
133<!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
134</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html>
135HTTP/1.1 404 Not Found
136Host: %s
137Date: %s
138Connection: close
139Content-Type: text/html; charset=UTF-8
140Content-Length: %d
141
142<!doctype html><html><head><title>404 Not Found</title><style>AAA</style>
143</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>
144HTTP/1.1 404 Not Found
145Host: %s
146Date: %s
147Connection: close
148Content-Type: text/html; charset=UTF-8
149Content-Length: %d
150
151
152HTTP/1.1 405 Method Not Allowed
153Host: %s
154Date: %s
155Connection: close
156Content-Type: text/html; charset=UTF-8
157Content-Length: %d
158Allow: GET, HEAD, POST
159
160<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
161</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>
162HTTP/1.1 405 Method Not Allowed
163Host: %s
164Date: %s
165Connection: close
166Content-Type: text/html; charset=UTF-8
167Content-Length: %d
168Allow: GET, HEAD, POST
169
170<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
171</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>
172HTTP/1.1 405 Method Not Allowed
173Host: %s
174Date: %s
175Connection: close
176Content-Type: text/html; charset=UTF-8
177Content-Length: %d
178Allow: GET, HEAD, POST
179
180<!doctype html><html><head><title>405 Method Not Allowed</title><style>AAA</style>
181</head><body><h1>Method Not Allowed</h1><p>Requested method not allowed.</p></body></html>
182