1--TEST--
2Stream: RFC2397 getting meta data
3--INI--
4allow_url_fopen=1
5--FILE--
6<?php
7
8$streams = array(
9	'data://,',
10	'data://',
11	'data://;base64,',
12	'data://;base64',
13	'data://foo,',
14	'data://foo=bar,',
15	'data://text/plain,',
16	'data://text/plain;foo,',
17	'data://text/plain;foo=bar,',
18	'data://text/plain;foo=bar;bla,',
19	'data://text/plain;foo=bar;base64,',
20	'data://text/plain;foo=bar;bar=baz',
21	'data://text/plain;foo=bar;bar=baz,',
22	);
23
24foreach($streams as $stream)
25{
26	$stream = fopen($stream, 'r');
27	$meta = @stream_get_meta_data($stream);
28	var_dump($meta);
29	var_dump(isset($meta['foo']) ? $meta['foo'] : null);
30}
31
32?>
33===DONE===
34<?php exit(0); ?>
35--EXPECTF--
36array(7) {
37  ["base64"]=>
38  bool(false)
39  ["wrapper_type"]=>
40  string(7) "RFC2397"
41  ["stream_type"]=>
42  string(7) "RFC2397"
43  ["mode"]=>
44  string(1) "r"
45  ["unread_bytes"]=>
46  int(0)
47  ["seekable"]=>
48  bool(true)
49  ["uri"]=>
50  string(8) "data://,"
51}
52NULL
53
54Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
55NULL
56NULL
57array(7) {
58  ["base64"]=>
59  bool(true)
60  ["wrapper_type"]=>
61  string(7) "RFC2397"
62  ["stream_type"]=>
63  string(7) "RFC2397"
64  ["mode"]=>
65  string(1) "r"
66  ["unread_bytes"]=>
67  int(0)
68  ["seekable"]=>
69  bool(true)
70  ["uri"]=>
71  string(15) "data://;base64,"
72}
73NULL
74
75Warning: fopen(data://;base64): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
76NULL
77NULL
78
79Warning: fopen(data://foo,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
80NULL
81NULL
82
83Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
84NULL
85NULL
86array(8) {
87  ["mediatype"]=>
88  string(10) "text/plain"
89  ["base64"]=>
90  bool(false)
91  ["wrapper_type"]=>
92  string(7) "RFC2397"
93  ["stream_type"]=>
94  string(7) "RFC2397"
95  ["mode"]=>
96  string(1) "r"
97  ["unread_bytes"]=>
98  int(0)
99  ["seekable"]=>
100  bool(true)
101  ["uri"]=>
102  string(18) "data://text/plain,"
103}
104NULL
105
106Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
107NULL
108NULL
109array(9) {
110  ["mediatype"]=>
111  string(10) "text/plain"
112  ["foo"]=>
113  string(3) "bar"
114  ["base64"]=>
115  bool(false)
116  ["wrapper_type"]=>
117  string(7) "RFC2397"
118  ["stream_type"]=>
119  string(7) "RFC2397"
120  ["mode"]=>
121  string(1) "r"
122  ["unread_bytes"]=>
123  int(0)
124  ["seekable"]=>
125  bool(true)
126  ["uri"]=>
127  string(26) "data://text/plain;foo=bar,"
128}
129string(3) "bar"
130
131Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
132NULL
133NULL
134array(9) {
135  ["mediatype"]=>
136  string(10) "text/plain"
137  ["foo"]=>
138  string(3) "bar"
139  ["base64"]=>
140  bool(true)
141  ["wrapper_type"]=>
142  string(7) "RFC2397"
143  ["stream_type"]=>
144  string(7) "RFC2397"
145  ["mode"]=>
146  string(1) "r"
147  ["unread_bytes"]=>
148  int(0)
149  ["seekable"]=>
150  bool(true)
151  ["uri"]=>
152  string(33) "data://text/plain;foo=bar;base64,"
153}
154string(3) "bar"
155
156Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
157NULL
158NULL
159array(10) {
160  ["mediatype"]=>
161  string(10) "text/plain"
162  ["foo"]=>
163  string(3) "bar"
164  ["bar"]=>
165  string(3) "baz"
166  ["base64"]=>
167  bool(false)
168  ["wrapper_type"]=>
169  string(7) "RFC2397"
170  ["stream_type"]=>
171  string(7) "RFC2397"
172  ["mode"]=>
173  string(1) "r"
174  ["unread_bytes"]=>
175  int(0)
176  ["seekable"]=>
177  bool(true)
178  ["uri"]=>
179  string(34) "data://text/plain;foo=bar;bar=baz,"
180}
181string(3) "bar"
182===DONE===
183