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    if ($stream) {
28        $meta = stream_get_meta_data($stream);
29        var_dump($meta);
30        var_dump(isset($meta['foo']) ? $meta['foo'] : null);
31    }
32}
33
34?>
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
55array(7) {
56  ["base64"]=>
57  bool(true)
58  ["wrapper_type"]=>
59  string(7) "RFC2397"
60  ["stream_type"]=>
61  string(7) "RFC2397"
62  ["mode"]=>
63  string(1) "r"
64  ["unread_bytes"]=>
65  int(0)
66  ["seekable"]=>
67  bool(true)
68  ["uri"]=>
69  string(15) "data://;base64,"
70}
71NULL
72
73Warning: fopen(data://;base64): Failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
74
75Warning: fopen(data://foo,): Failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
76
77Warning: fopen(data://foo=bar,): Failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
78array(8) {
79  ["mediatype"]=>
80  string(10) "text/plain"
81  ["base64"]=>
82  bool(false)
83  ["wrapper_type"]=>
84  string(7) "RFC2397"
85  ["stream_type"]=>
86  string(7) "RFC2397"
87  ["mode"]=>
88  string(1) "r"
89  ["unread_bytes"]=>
90  int(0)
91  ["seekable"]=>
92  bool(true)
93  ["uri"]=>
94  string(18) "data://text/plain,"
95}
96NULL
97
98Warning: fopen(data://text/plain;foo,): Failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
99array(9) {
100  ["mediatype"]=>
101  string(10) "text/plain"
102  ["foo"]=>
103  string(3) "bar"
104  ["base64"]=>
105  bool(false)
106  ["wrapper_type"]=>
107  string(7) "RFC2397"
108  ["stream_type"]=>
109  string(7) "RFC2397"
110  ["mode"]=>
111  string(1) "r"
112  ["unread_bytes"]=>
113  int(0)
114  ["seekable"]=>
115  bool(true)
116  ["uri"]=>
117  string(26) "data://text/plain;foo=bar,"
118}
119string(3) "bar"
120
121Warning: fopen(data://text/plain;foo=bar;bla,): Failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
122array(9) {
123  ["mediatype"]=>
124  string(10) "text/plain"
125  ["foo"]=>
126  string(3) "bar"
127  ["base64"]=>
128  bool(true)
129  ["wrapper_type"]=>
130  string(7) "RFC2397"
131  ["stream_type"]=>
132  string(7) "RFC2397"
133  ["mode"]=>
134  string(1) "r"
135  ["unread_bytes"]=>
136  int(0)
137  ["seekable"]=>
138  bool(true)
139  ["uri"]=>
140  string(33) "data://text/plain;foo=bar;base64,"
141}
142string(3) "bar"
143
144Warning: 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
145array(10) {
146  ["mediatype"]=>
147  string(10) "text/plain"
148  ["foo"]=>
149  string(3) "bar"
150  ["bar"]=>
151  string(3) "baz"
152  ["base64"]=>
153  bool(false)
154  ["wrapper_type"]=>
155  string(7) "RFC2397"
156  ["stream_type"]=>
157  string(7) "RFC2397"
158  ["mode"]=>
159  string(1) "r"
160  ["unread_bytes"]=>
161  int(0)
162  ["seekable"]=>
163  bool(true)
164  ["uri"]=>
165  string(34) "data://text/plain;foo=bar;bar=baz,"
166}
167string(3) "bar"
168