- ws
[m6w6/ext-http] / tests / HttpMessage_001.phpt
1 --TEST--
2 HttpMessage
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin(5);
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11 $m = new HttpMessage(
12 "HTTP/1.1 301\r\n".
13 "Location: /anywhere\r\n".
14 "HTTP/1.1 302\r\n".
15 "Location: /somewhere\r\n".
16 "HTTP/1.1 206 Partial content\r\n".
17 "Content-Range: bytes=2-3\r\n".
18 "Transfer-Encoding: chunked\r\n".
19 "\r\n".
20 "01\r\n".
21 "X\r\n".
22 "00"
23 );
24
25 var_dump($m->getResponseStatus());
26
27 $x = $m->getParentMessage();
28 $x = $m->getParentMessage();
29 $x = $m->getParentMessage();
30
31 var_dump($m->getBody());
32 var_dump(HttpMessage::fromString($m->toString(true))->toString(true));
33 do {
34 var_dump($m->toString());
35 } while ($m = $m->getParentMessage());
36
37 echo "Done\n";
38 ?>
39 --EXPECTF--
40 %sTEST
41 string(15) "Partial content"
42 string(1) "X"
43 string(190) "HTTP/1.1 301
44 Location: /anywhere
45 HTTP/1.1 302
46 Location: /somewhere
47 HTTP/1.1 206 Partial content
48 Content-Range: bytes=2-3
49 X-Original-Transfer-Encoding: chunked
50 Content-Length: 1
51
52 X
53 "
54 string(119) "HTTP/1.1 206 Partial content
55 Content-Range: bytes=2-3
56 X-Original-Transfer-Encoding: chunked
57 Content-Length: 1
58
59 X
60 "
61 string(36) "HTTP/1.1 302
62 Location: /somewhere
63 "
64 string(35) "HTTP/1.1 301
65 Location: /anywhere
66 "
67 Done