fix #98 #99 #100 #101 #102 #103
[m6w6/ext-http] / tests / info002.phpt
1 --TEST--
2 invalid HTTP info
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --INI--
8 zend.exception_ignore_args=off
9 --FILE--
10 <?php
11
12 echo "Test\n";
13
14 function trap($cb) {
15 try {
16 $cb();
17 } catch (Exception $e) {
18 echo $e,"\n";
19 }
20 }
21
22 trap(function() {
23 echo new http\Message("HTTP/1.1 99 Apples in my Basket");
24 });
25
26 trap(function() {
27 echo new http\Message("CONNECT HTTP/1.1");
28 });
29
30 echo new http\Message("HTTP/1.1");
31 echo new http\Message("CONNECT www.example.org:80 HTTP/1.1");
32
33 ?>
34 ===DONE===
35 --EXPECTF--
36 Test
37 http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\057' at pos 4 of 'HTTP/1.1 99 Apples in my Basket' in %sinfo002.php:%d
38 Stack trace:
39 #0 %sinfo002.php(%d): http\Message->__construct('HTTP/1.1 99 App...')
40 #1 %sinfo002.php(%d): {closure}()
41 #2 %sinfo002.php(%d): trap(Object(Closure))
42 #3 {main}
43 http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\040' at pos 7 of 'CONNECT HTTP/1.1' in %sinfo002.php:%d
44 Stack trace:
45 #0 %sinfo002.php(%d): http\Message->__construct('CONNECT HTTP/1....')
46 #1 %sinfo002.php(%d): {closure}()
47 #2 %sinfo002.php(%d): trap(Object(Closure))
48 #3 {main}
49 HTTP/1.1 200
50 CONNECT www.example.org:80 HTTP/1.1
51 ===DONE===