set always_populate_raw_post_data=-1 to avoid failed test (because of warning)
[m6w6/ext-http] / tests / message002.phpt
1 --TEST--
2 env request message
3 --SKIPIF--
4 <?php include "skipif.inc"; ?>
5 --POST_RAW--
6 Content-Type: test/something
7 b=c
8 --ENV--
9 HTTP_X_TEST=test
10 --COOKIE--
11 foo=bar
12 --INI--
13 always_populate_raw_post_data=-1
14 --FILE--
15 <?php
16 echo "Test\n";
17
18 use http\env\Request as HttpEnvRequest;
19
20 $m = new HttpEnvRequest();
21
22 var_dump($m);
23
24 echo "Message->toString\n";
25 echo $m,"\n";
26
27 echo "Body->toString\n";
28 var_dump((string)$m->getBody());
29
30 echo "stream\n";
31 var_dump(file_get_contents("php://input"));
32 ?>
33 Done
34 --EXPECTF--
35 Test
36 object(%s)#%d (12) {
37 ["type":protected]=>
38 int(1)
39 ["body":protected]=>
40 object(http\Message\Body)#%d (0) {
41 }
42 ["requestMethod":protected]=>
43 string(4) "POST"
44 ["requestUrl":protected]=>
45 string(0) ""
46 ["responseStatus":protected]=>
47 string(0) ""
48 ["responseCode":protected]=>
49 int(0)
50 ["httpVersion":protected]=>
51 string(3) "1.1"
52 ["headers":protected]=>
53 array(4) {
54 ["X-Test"]=>
55 string(4) "test"
56 ["Content-Length"]=>
57 string(1) "3"
58 ["Content-Type"]=>
59 string(14) "test/something"
60 ["Cookie"]=>
61 string(7) "foo=bar"
62 }
63 ["parentMessage":protected]=>
64 NULL
65 ["query":protected]=>
66 object(http\QueryString)#2 (1) {
67 ["queryArray":"http\QueryString":private]=>
68 array(0) {
69 }
70 }
71 ["form":protected]=>
72 object(http\QueryString)#3 (1) {
73 ["queryArray":"http\QueryString":private]=>
74 array(0) {
75 }
76 }
77 ["files":protected]=>
78 array(0) {
79 }
80 }
81 Message->toString
82 POST / HTTP/1.1%a
83 X-Test: test%a
84 Content-Length: 3%a
85 Content-Type: test/something%a
86 Cookie: foo=bar%a
87 %a
88 b=c
89 Body->toString
90 string(3) "b=c"
91 stream
92 string(3) "b=c"
93 Done