Annotation of embedaddon/php/ext/standard/tests/http/ignore_errors.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: http:// and ignore_errors
3: --INI--
4: allow_url_fopen=1
5: --SKIPIF--
6: <?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
7: --FILE--
8: <?php
9: require 'server.inc';
10:
11: function do_test($context_options) {
12:
13: $context = stream_context_create(array('http' => $context_options));
14:
15: $responses = array(
16: "data://text/plain,HTTP/1.0 200 Ok\r\nX-Foo: bar\r\n\r\n1",
17: "data://text/plain,HTTP/1.0 404 Not found\r\nX-bar: baz\r\n\r\n2",
18: );
19:
20: $pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
21:
22: foreach($responses as $r) {
23:
24: $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context);
25: var_dump($fd);
26:
27: if ($fd) {
28: $meta_data = stream_get_meta_data($fd);
29: var_dump($meta_data['wrapper_data']);
30:
31: var_dump(stream_get_contents($fd));
32: }
33:
34: fseek($output, 0, SEEK_SET);
35: var_dump(stream_get_contents($output));
36: fseek($output, 0, SEEK_SET);
37: }
38:
39: http_server_kill($pid);
40: }
41:
42: echo "-- Test: requests without ignore_errors --\n";
43:
44: do_test(array());
45:
46: echo "-- Test: requests with ignore_errors --\n";
47:
48: do_test(array('ignore_errors' => true));
49:
50: echo "-- Test: requests with ignore_errors (2) --\n";
51:
52: do_test(array('ignore_errors' => 1));
53:
54: ?>
55: --EXPECTF--
56: -- Test: requests without ignore_errors --
57: resource(%d) of type (stream)
58: array(2) {
59: [0]=>
60: string(15) "HTTP/1.0 200 Ok"
61: [1]=>
62: string(10) "X-Foo: bar"
63: }
64: string(1) "1"
65: string(48) "GET /foo/bar HTTP/1.0
66: Host: 127.0.0.1:12342
67:
68: "
69:
70: Warning: fopen(http://127.0.0.1:12342/foo/bar): failed to open stream: HTTP request failed! HTTP/1.0 404 Not found
71: in %s on line %d
72: bool(false)
73: string(48) "GET /foo/bar HTTP/1.0
74: Host: 127.0.0.1:12342
75:
76: "
77: -- Test: requests with ignore_errors --
78: resource(%d) of type (stream)
79: array(2) {
80: [0]=>
81: string(15) "HTTP/1.0 200 Ok"
82: [1]=>
83: string(10) "X-Foo: bar"
84: }
85: string(1) "1"
86: string(48) "GET /foo/bar HTTP/1.0
87: Host: 127.0.0.1:12342
88:
89: "
90: resource(%d) of type (stream)
91: array(2) {
92: [0]=>
93: string(22) "HTTP/1.0 404 Not found"
94: [1]=>
95: string(10) "X-bar: baz"
96: }
97: string(1) "2"
98: string(48) "GET /foo/bar HTTP/1.0
99: Host: 127.0.0.1:12342
100:
101: "
102: -- Test: requests with ignore_errors (2) --
103: resource(%d) of type (stream)
104: array(2) {
105: [0]=>
106: string(15) "HTTP/1.0 200 Ok"
107: [1]=>
108: string(10) "X-Foo: bar"
109: }
110: string(1) "1"
111: string(48) "GET /foo/bar HTTP/1.0
112: Host: 127.0.0.1:12342
113:
114: "
115: resource(%d) of type (stream)
116: array(2) {
117: [0]=>
118: string(22) "HTTP/1.0 404 Not found"
119: [1]=>
120: string(10) "X-bar: baz"
121: }
122: string(1) "2"
123: string(48) "GET /foo/bar HTTP/1.0
124: Host: 127.0.0.1:12342
125:
126: "
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>