tests
[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 $m = new HttpMessage();
14 echo $m;
15 var_dump(
16 $m->getHttpVersion(),
17 $m->getType()==HttpMessage::TYPE_NONE,
18 $m->getHeaders()
19 );
20
21 $m = new HttpMessage("GET / HTTP/1.1\r\n");
22 echo $m;
23 var_dump(
24 $m->getHttpVersion(),
25 $m->getType()==HttpMessage::TYPE_REQUEST,
26 $m->getRequestMethod(),
27 $m->getRequestUrl(),
28 $m->getHeaders()
29 );
30
31 $m = new HttpMessage("HTTP/1.1 200 Okidoki\r\n");
32 echo $m;
33 var_dump(
34 $m->getHttpVersion(),
35 $m->getType()==HttpMessage::TYPE_RESPONSE,
36 $m->getResponseCode(),
37 $m->getResponseStatus(),
38 $m->getHeaders()
39 );
40
41 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty.txt"));
42 echo $m;
43 var_dump(
44 $m->getHttpVersion(),
45 $m->getType()==HttpMessage::TYPE_RESPONSE,
46 $m->getResponseCode(),
47 $m->getResponseStatus(),
48 $m->getHeaders()
49 );
50 echo $m->getParentMessage();
51
52 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty_gzip.txt"));
53 echo $m;
54 var_dump(
55 $m->getHttpVersion(),
56 $m->getType()==HttpMessage::TYPE_RESPONSE,
57 $m->getResponseCode(),
58 $m->getResponseStatus(),
59 $m->getHeaders()
60 );
61 echo $m->getParentMessage();
62
63 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_empty_chunked.txt"));
64 echo $m;
65 var_dump(
66 $m->getHttpVersion(),
67 $m->getType()==HttpMessage::TYPE_RESPONSE,
68 $m->getResponseCode(),
69 $m->getResponseStatus(),
70 $m->getHeaders()
71 );
72 echo $m->getParentMessage();
73
74 $m = new HttpMessage(file_get_contents(__DIR__."/data/message_rr_helloworld_chunked.txt"));
75 echo $m;
76 var_dump(
77 $m->getHttpVersion(),
78 $m->getType()==HttpMessage::TYPE_RESPONSE,
79 $m->getResponseCode(),
80 $m->getResponseStatus(),
81 $m->getHeaders()
82 );
83 echo $m->getParentMessage();
84
85 echo "Done\n";
86 --EXPECTF--
87 Test
88 string(3) "0.0"
89 bool(true)
90 array(0) {
91 }
92 GET / HTTP/1.1
93 string(3) "1.1"
94 bool(true)
95 string(3) "GET"
96 string(1) "/"
97 array(0) {
98 }
99 HTTP/1.1 200 Okidoki
100 string(3) "1.1"
101 bool(true)
102 int(200)
103 string(7) "Okidoki"
104 array(0) {
105 }
106 HTTP/1.1 200 OK
107 Date: Wed, 25 Aug 2010 12:11:44 GMT
108 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
109 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
110 Etag: "2002a-0-48549d615a35c"
111 Accept-Ranges: bytes
112 Content-Length: 0
113 Vary: Accept-Encoding
114 Connection: close
115 Content-Type: text/plain
116 X-Original-Content-Length: 0
117 string(3) "1.1"
118 bool(true)
119 int(200)
120 string(2) "OK"
121 array(10) {
122 ["Date"]=>
123 string(29) "Wed, 25 Aug 2010 12:11:44 GMT"
124 ["Server"]=>
125 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
126 ["Last-Modified"]=>
127 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
128 ["Etag"]=>
129 string(23) ""2002a-0-48549d615a35c""
130 ["Accept-Ranges"]=>
131 string(5) "bytes"
132 ["Content-Length"]=>
133 int(0)
134 ["Vary"]=>
135 string(15) "Accept-Encoding"
136 ["Connection"]=>
137 string(5) "close"
138 ["Content-Type"]=>
139 string(10) "text/plain"
140 ["X-Original-Content-Length"]=>
141 string(1) "0"
142 }
143 GET /default/empty.txt HTTP/1.1
144 Host: localhost
145 Connection: close
146 Content-Length: 0
147 HTTP/1.1 200 OK
148 Date: Thu, 26 Aug 2010 09:55:09 GMT
149 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
150 Last-Modified: Wed, 28 Apr 2010 10:54:37 GMT
151 Etag: "2002a-0-48549d615a35c"
152 Accept-Ranges: bytes
153 Vary: Accept-Encoding
154 Content-Length: 0
155 Connection: close
156 Content-Type: text/plain
157 X-Original-Content-Length: 20
158 X-Original-Content-Encoding: gzip
159 string(3) "1.1"
160 bool(true)
161 int(200)
162 string(2) "OK"
163 array(11) {
164 ["Date"]=>
165 string(29) "Thu, 26 Aug 2010 09:55:09 GMT"
166 ["Server"]=>
167 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
168 ["Last-Modified"]=>
169 string(29) "Wed, 28 Apr 2010 10:54:37 GMT"
170 ["Etag"]=>
171 string(23) ""2002a-0-48549d615a35c""
172 ["Accept-Ranges"]=>
173 string(5) "bytes"
174 ["Vary"]=>
175 string(15) "Accept-Encoding"
176 ["Content-Length"]=>
177 int(0)
178 ["Connection"]=>
179 string(5) "close"
180 ["Content-Type"]=>
181 string(10) "text/plain"
182 ["X-Original-Content-Length"]=>
183 string(2) "20"
184 ["X-Original-Content-Encoding"]=>
185 string(4) "gzip"
186 }
187 GET /default/empty.txt HTTP/1.1
188 Host: localhost
189 Accept-Encoding: gzip
190 Connection: close
191 Content-Length: 0
192 HTTP/1.1 200 OK
193 Date: Thu, 26 Aug 2010 11:41:02 GMT
194 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
195 X-Powered-By: PHP/5.3.3
196 Vary: Accept-Encoding
197 Connection: close
198 Content-Type: text/html
199 X-Original-Transfer-Encoding: chunked
200 Content-Length: 0
201 string(3) "1.1"
202 bool(true)
203 int(200)
204 string(2) "OK"
205 array(8) {
206 ["Date"]=>
207 string(29) "Thu, 26 Aug 2010 11:41:02 GMT"
208 ["Server"]=>
209 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
210 ["X-Powered-By"]=>
211 string(9) "PHP/5.3.3"
212 ["Vary"]=>
213 string(15) "Accept-Encoding"
214 ["Connection"]=>
215 string(5) "close"
216 ["Content-Type"]=>
217 string(9) "text/html"
218 ["X-Original-Transfer-Encoding"]=>
219 string(7) "chunked"
220 ["Content-Length"]=>
221 int(0)
222 }
223 GET /default/empty.php HTTP/1.1
224 Connection: close
225 Host: localhost
226 Content-Length: 0
227 HTTP/1.1 200 OK
228 Date: Thu, 26 Aug 2010 12:51:28 GMT
229 Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
230 Vary: Accept-Encoding
231 Connection: close
232 Content-Type: text/plain
233 X-Original-Transfer-Encoding: chunked
234 Content-Length: 14
235
236 Hello, World!
237
238 string(3) "1.1"
239 bool(true)
240 int(200)
241 string(2) "OK"
242 array(7) {
243 ["Date"]=>
244 string(29) "Thu, 26 Aug 2010 12:51:28 GMT"
245 ["Server"]=>
246 string(68) "Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6"
247 ["Vary"]=>
248 string(15) "Accept-Encoding"
249 ["Connection"]=>
250 string(5) "close"
251 ["Content-Type"]=>
252 string(10) "text/plain"
253 ["X-Original-Transfer-Encoding"]=>
254 string(7) "chunked"
255 ["Content-Length"]=>
256 int(14)
257 }
258 GET /cgi-bin/chunked.sh HTTP/1.1
259 Host: localhost
260 Connection: close
261 Content-Length: 0
262 Done