prepare v4.2.5
[m6w6/ext-http] / tests / message001.phpt
1 --TEST--
2 message
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 use http\Message as HttpMessage;
12
13 try {
14 echo new HttpMessage(" gosh\n nosh\n ");
15 } catch (Exception $ignore) {
16 }
17
18 $m = new HttpMessage();
19 echo $m;
20 var_dump(
21 $m->getHttpVersion(),
22 $m->getType()==HttpMessage::TYPE_NONE,
23 $m->getHeaders()
24 );
25
26 $m = new HttpMessage("GET / HTTP/1.1\r\n");
27 echo $m;
28 var_dump(
29 $m->getHttpVersion(),
30 $m->getType()==HttpMessage::TYPE_REQUEST,
31 $m->getRequestMethod(),
32 $m->getRequestUrl(),
33 $m->getHeaders()
34 );
35
36 $m = new HttpMessage("HTTP/1.1 200 Okidoki\r\n");
37 echo $m;
38 var_dump(
39 $m->getHttpVersion(),
40 $m->getType()==HttpMessage::TYPE_RESPONSE,
41 $m->getResponseCode(),
42 $m->getResponseStatus(),
43 $m->getHeaders()
44 );
45
46 echo "---\n";
47
48 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty.txt"));
49 echo $m;
50 var_dump(
51 $m->getHttpVersion(),
52 $m->getType()==HttpMessage::TYPE_RESPONSE,
53 $m->getResponseCode(),
54 $m->getResponseStatus(),
55 $m->getHeaders()
56 );
57 echo $m->getParentMessage();
58
59 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty_gzip.txt"));
60 echo $m;
61 var_dump(
62 $m->getHttpVersion(),
63 $m->getType()==HttpMessage::TYPE_RESPONSE,
64 $m->getResponseCode(),
65 $m->getResponseStatus(),
66 $m->getHeaders()
67 );
68 echo $m->getParentMessage();
69
70 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty_chunked.txt"));
71 echo $m;
72 var_dump(
73 $m->getHttpVersion(),
74 $m->getType()==HttpMessage::TYPE_RESPONSE,
75 $m->getResponseCode(),
76 $m->getResponseStatus(),
77 $m->getHeaders()
78 );
79 echo $m->getParentMessage();
80
81 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_helloworld_chunked.txt"));
82 echo $m;
83 var_dump(
84 $m->getHttpVersion(),
85 $m->getType()==HttpMessage::TYPE_RESPONSE,
86 $m->getResponseCode(),
87 $m->getResponseStatus(),
88 $m->getHeaders()
89 );
90 echo $m->getParentMessage();
91
92 echo "---\n";
93
94 $m = new HttpMessage(fopen(__DIR__."/data/message_rr_empty.txt", "r+b"));
95 echo $m;
96 var_dump(
97 $m->getHttpVersion(),
98 $m->getType()==HttpMessage::TYPE_RESPONSE,
99 $m->getResponseCode(),
100 $m->getResponseStatus(),
101 $m->getHeaders()
102 );
103 echo $m->getParentMessage();
104
105 $m = new HttpMessage(fopen(__DIR__."/data/message_rr_empty_gzip.txt", "r+b"));
106 echo $m;
107 var_dump(
108 $m->getHttpVersion(),
109 $m->getType()==HttpMessage::TYPE_RESPONSE,
110 $m->getResponseCode(),
111 $m->getResponseStatus(),
112 $m->getHeaders()
113 );
114 echo $m->getParentMessage();
115
116 $m = new HttpMessage(fopen(__DIR__."/data/message_rr_empty_chunked.txt", "r+b"));
117 echo $m;
118 var_dump(
119 $m->getHttpVersion(),
120 $m->getType()==HttpMessage::TYPE_RESPONSE,
121 $m->getResponseCode(),
122 $m->getResponseStatus(),
123 $m->getHeaders()
124 );
125 echo $m->getParentMessage();
126
127 $m = new HttpMessage(fopen(__DIR__."/data/message_rr_helloworld_chunked.txt", "r+b"));
128 echo $m;
129 var_dump(
130 $m->getHttpVersion(),
131 $m->getType()==HttpMessage::TYPE_RESPONSE,
132 $m->getResponseCode(),
133 $m->getResponseStatus(),
134 $m->getHeaders()
135 );
136 echo $m->getParentMessage();
137
138 echo "Done\n";
139 --EXPECTF--
140 Test
141 string(3) "1.1"
142 bool(true)
143 array(0) {
144 }
145 GET / HTTP/1.1
146 string(3) "1.1"
147 bool(true)
148 string(3) "GET"
149 string(1) "/"
150 array(0) {
151 }
152 HTTP/1.1 200 Okidoki
153 string(3) "1.1"
154 bool(true)
155 int(200)
156 string(7) "Okidoki"
157 array(0) {
158 }
159 ---
160 HTTP/1.1 200 OK
161 Date: Wed, 25 Aug 2010 12:11:44 GMT
162 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
163 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
164 Etag: "2002a-0-48549d615a35c"
165 Accept-Ranges: bytes
166 Content-Length: 0
167 Vary: Accept-Encoding
168 Connection: close
169 Content-Type: text/plain
170 X-Original-Content-Length: 0
171 string(3) "1.1"
172 bool(true)
173 int(200)
174 string(2) "OK"
175 array(10) {
176 ["Date"]=>
177 string(29) "Wed, 25 Aug 2010 12:11:44 GMT"
178 ["Server"]=>
179 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
180 ["Last-Modified"]=>
181 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
182 ["Etag"]=>
183 string(23) ""2002a-0-48549d615a35c""
184 ["Accept-Ranges"]=>
185 string(5) "bytes"
186 ["Content-Length"]=>
187 string(1) "0"
188 ["Vary"]=>
189 string(15) "Accept-Encoding"
190 ["Connection"]=>
191 string(5) "close"
192 ["Content-Type"]=>
193 string(10) "text/plain"
194 ["X-Original-Content-Length"]=>
195 string(1) "0"
196 }
197 GET /default/empty.txt HTTP/1.1
198 Host: localhost
199 Connection: close
200 HTTP/1.1 200 OK
201 Date: Thu, 26 Aug 2010 09:55:09 GMT
202 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
203 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
204 Etag: "2002a-0-48549d615a35c"
205 Accept-Ranges: bytes
206 Vary: Accept-Encoding
207 Connection: close
208 Content-Type: text/plain
209 X-Original-Content-Length: 20
210 X-Original-Content-Encoding: gzip
211 string(3) "1.1"
212 bool(true)
213 int(200)
214 string(2) "OK"
215 array(10) {
216 ["Date"]=>
217 string(29) "Thu, 26 Aug 2010 09:55:09 GMT"
218 ["Server"]=>
219 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
220 ["Last-Modified"]=>
221 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
222 ["Etag"]=>
223 string(23) ""2002a-0-48549d615a35c""
224 ["Accept-Ranges"]=>
225 string(5) "bytes"
226 ["Vary"]=>
227 string(15) "Accept-Encoding"
228 ["Connection"]=>
229 string(5) "close"
230 ["Content-Type"]=>
231 string(10) "text/plain"
232 ["X-Original-Content-Length"]=>
233 string(2) "20"
234 ["X-Original-Content-Encoding"]=>
235 string(4) "gzip"
236 }
237 GET /default/empty.txt HTTP/1.1
238 Host: localhost
239 Accept-Encoding: gzip
240 Connection: close
241 HTTP/1.1 200 OK
242 Date: Thu, 26 Aug 2010 11:41:02 GMT
243 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
244 X-Powered-By: PHP/5.3.3
245 Vary: Accept-Encoding
246 Connection: close
247 Content-Type: text/html
248 X-Original-Transfer-Encoding: chunked
249 Content-Length: 0
250 string(3) "1.1"
251 bool(true)
252 int(200)
253 string(2) "OK"
254 array(8) {
255 ["Date"]=>
256 string(29) "Thu, 26 Aug 2010 11:41:02 GMT"
257 ["Server"]=>
258 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
259 ["X-Powered-By"]=>
260 string(9) "PHP/5.3.3"
261 ["Vary"]=>
262 string(15) "Accept-Encoding"
263 ["Connection"]=>
264 string(5) "close"
265 ["Content-Type"]=>
266 string(9) "text/html"
267 ["X-Original-Transfer-Encoding"]=>
268 string(7) "chunked"
269 ["Content-Length"]=>
270 int(0)
271 }
272 GET /default/empty.php HTTP/1.1
273 Connection: close
274 Host: localhost
275 HTTP/1.1 200 OK
276 Date: Thu, 26 Aug 2010 12:51:28 GMT
277 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
278 Vary: Accept-Encoding
279 Connection: close
280 Content-Type: text/plain
281 X-Original-Transfer-Encoding: chunked
282 Content-Length: 14
283
284 Hello, World!
285 string(3) "1.1"
286 bool(true)
287 int(200)
288 string(2) "OK"
289 array(7) {
290 ["Date"]=>
291 string(29) "Thu, 26 Aug 2010 12:51:28 GMT"
292 ["Server"]=>
293 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
294 ["Vary"]=>
295 string(15) "Accept-Encoding"
296 ["Connection"]=>
297 string(5) "close"
298 ["Content-Type"]=>
299 string(10) "text/plain"
300 ["X-Original-Transfer-Encoding"]=>
301 string(7) "chunked"
302 ["Content-Length"]=>
303 int(14)
304 }
305 GET /cgi-bin/chunked.sh HTTP/1.1
306 Host: localhost
307 Connection: close
308 ---
309 HTTP/1.1 200 OK
310 Date: Wed, 25 Aug 2010 12:11:44 GMT
311 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
312 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
313 Etag: "2002a-0-48549d615a35c"
314 Accept-Ranges: bytes
315 Content-Length: 0
316 Vary: Accept-Encoding
317 Connection: close
318 Content-Type: text/plain
319 X-Original-Content-Length: 0
320 string(3) "1.1"
321 bool(true)
322 int(200)
323 string(2) "OK"
324 array(10) {
325 ["Date"]=>
326 string(29) "Wed, 25 Aug 2010 12:11:44 GMT"
327 ["Server"]=>
328 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
329 ["Last-Modified"]=>
330 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
331 ["Etag"]=>
332 string(23) ""2002a-0-48549d615a35c""
333 ["Accept-Ranges"]=>
334 string(5) "bytes"
335 ["Content-Length"]=>
336 string(1) "0"
337 ["Vary"]=>
338 string(15) "Accept-Encoding"
339 ["Connection"]=>
340 string(5) "close"
341 ["Content-Type"]=>
342 string(10) "text/plain"
343 ["X-Original-Content-Length"]=>
344 string(1) "0"
345 }
346 GET /default/empty.txt HTTP/1.1
347 Host: localhost
348 Connection: close
349 HTTP/1.1 200 OK
350 Date: Thu, 26 Aug 2010 09:55:09 GMT
351 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
352 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
353 Etag: "2002a-0-48549d615a35c"
354 Accept-Ranges: bytes
355 Vary: Accept-Encoding
356 Connection: close
357 Content-Type: text/plain
358 X-Original-Content-Length: 20
359 X-Original-Content-Encoding: gzip
360 string(3) "1.1"
361 bool(true)
362 int(200)
363 string(2) "OK"
364 array(10) {
365 ["Date"]=>
366 string(29) "Thu, 26 Aug 2010 09:55:09 GMT"
367 ["Server"]=>
368 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
369 ["Last-Modified"]=>
370 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
371 ["Etag"]=>
372 string(23) ""2002a-0-48549d615a35c""
373 ["Accept-Ranges"]=>
374 string(5) "bytes"
375 ["Vary"]=>
376 string(15) "Accept-Encoding"
377 ["Connection"]=>
378 string(5) "close"
379 ["Content-Type"]=>
380 string(10) "text/plain"
381 ["X-Original-Content-Length"]=>
382 string(2) "20"
383 ["X-Original-Content-Encoding"]=>
384 string(4) "gzip"
385 }
386 GET /default/empty.txt HTTP/1.1
387 Host: localhost
388 Accept-Encoding: gzip
389 Connection: close
390 HTTP/1.1 200 OK
391 Date: Thu, 26 Aug 2010 11:41:02 GMT
392 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
393 X-Powered-By: PHP/5.3.3
394 Vary: Accept-Encoding
395 Connection: close
396 Content-Type: text/html
397 X-Original-Transfer-Encoding: chunked
398 Content-Length: 0
399 string(3) "1.1"
400 bool(true)
401 int(200)
402 string(2) "OK"
403 array(8) {
404 ["Date"]=>
405 string(29) "Thu, 26 Aug 2010 11:41:02 GMT"
406 ["Server"]=>
407 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
408 ["X-Powered-By"]=>
409 string(9) "PHP/5.3.3"
410 ["Vary"]=>
411 string(15) "Accept-Encoding"
412 ["Connection"]=>
413 string(5) "close"
414 ["Content-Type"]=>
415 string(9) "text/html"
416 ["X-Original-Transfer-Encoding"]=>
417 string(7) "chunked"
418 ["Content-Length"]=>
419 int(0)
420 }
421 GET /default/empty.php HTTP/1.1
422 Connection: close
423 Host: localhost
424 HTTP/1.1 200 OK
425 Date: Thu, 26 Aug 2010 12:51:28 GMT
426 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
427 Vary: Accept-Encoding
428 Connection: close
429 Content-Type: text/plain
430 X-Original-Transfer-Encoding: chunked
431 Content-Length: 14
432
433 Hello, World!
434 string(3) "1.1"
435 bool(true)
436 int(200)
437 string(2) "OK"
438 array(7) {
439 ["Date"]=>
440 string(29) "Thu, 26 Aug 2010 12:51:28 GMT"
441 ["Server"]=>
442 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
443 ["Vary"]=>
444 string(15) "Accept-Encoding"
445 ["Connection"]=>
446 string(5) "close"
447 ["Content-Type"]=>
448 string(10) "text/plain"
449 ["X-Original-Transfer-Encoding"]=>
450 string(7) "chunked"
451 ["Content-Length"]=>
452 int(14)
453 }
454 GET /cgi-bin/chunked.sh HTTP/1.1
455 Host: localhost
456 Connection: close
457 Done