8f711c1ab18357a73c5b2e775fb383214da6af24
[m6w6/ext-http] / tests / HttpMessage_001.phpt
1 --TEST--
2 HttpMessage
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin(5.3);
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 try {
34 do {
35 var_dump($m->toString());
36 } while ($m = $m->getParentMessage());
37 } catch (HttpException $ex) {
38 }
39
40 echo "Done\n";
41 ?>
42 --EXPECTF--
43 %aTEST
44 string(15) "Partial content"
45 string(1) "X"
46 string(190) "HTTP/1.1 301
47 Location: /anywhere
48 HTTP/1.1 302
49 Location: /somewhere
50 HTTP/1.1 206 Partial content
51 Content-Range: bytes=2-3
52 X-Original-Transfer-Encoding: chunked
53 Content-Length: 1
54
55 X
56 "
57 string(119) "HTTP/1.1 206 Partial content
58 Content-Range: bytes=2-3
59 X-Original-Transfer-Encoding: chunked
60 Content-Length: 1
61
62 X
63 "
64 string(36) "HTTP/1.1 302
65 Location: /somewhere
66 "
67 string(35) "HTTP/1.1 301
68 Location: /anywhere
69 "
70 Done