Possible null pointer dereference in php_http_url_mod() fixed.
[m6w6/ext-http] / tests / messageparser002.phpt
1 --TEST--
2 message parser with nonblocking stream
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 $parser = new http\Message\Parser;
12 $socket = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
13 stream_set_blocking($socket[0], 0);
14
15 $message = array(
16 "GET / HTTP/1.1\n",
17 "Host: localhost\n",
18 "Content-length: 3\n",
19 "\n",
20 "OK\n"
21 );
22
23 while ($message) {
24 $line = array_shift($message);
25 $parser->stream($socket[0], 0, $msg);
26 fwrite($socket[1], $line);
27 $parser->stream($socket[0], 0, $msg);
28 }
29
30 var_dump($msg, (string) $msg->getBody());
31
32 ?>
33 DONE
34 --EXPECTF--
35 Test
36 object(http\Message)#%d (9) {
37 ["type":protected]=>
38 int(1)
39 ["body":protected]=>
40 object(http\Message\Body)#%d (0) {
41 }
42 ["requestMethod":protected]=>
43 string(3) "GET"
44 ["requestUrl":protected]=>
45 string(1) "/"
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(3) {
54 ["Host"]=>
55 string(9) "localhost"
56 ["Content-Length"]=>
57 string(1) "3"
58 ["X-Original-Content-Length"]=>
59 string(1) "3"
60 }
61 ["parentMessage":protected]=>
62 NULL
63 }
64 string(3) "OK
65 "
66 DONE