xref: /PHP-5.3/ext/standard/tests/file/bug52820.phpt (revision 63659ce5)
1--TEST--
2Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)
3--SKIPIF--
4<?php
5/* unfortunately no standard function does a cast to FILE*, so we need
6 * curl to test this */
7if (!extension_loaded("curl")) exit("skip curl extension not loaded");
8$handle=curl_init('http://127.0.0.1:37349/');
9curl_setopt($handle, CURLOPT_VERBOSE, true);
10curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
11if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
12    die("skip fopencookie not supported on this platform");
13--FILE--
14<?php
15function do_stuff($url) {
16    $handle=curl_init('http://127.0.0.1:37349/');
17    curl_setopt($handle, CURLOPT_VERBOSE, true);
18    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
19    curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
20    curl_exec($handle);
21    echo "About to rewind!\n";
22    rewind($o);
23    echo stream_get_contents($o);
24    return $o;
25}
26
27echo "temp stream (close after):\n";
28fclose(do_stuff("php://temp"));
29
30echo "\nmemory stream (close after):\n";
31fclose(do_stuff("php://memory"));
32
33echo "\nDone.\n";
34--EXPECTF--
35temp stream (close after):
36About to rewind!
37* About to connect() to 127.0.0.1 port 37349%r.*%r
38*   Trying 127.0.0.1...%A* Connection refused
39* couldn't connect to host%S
40* Closing connection #0
41
42memory stream (close after):
43About to rewind!
44* About to connect() to 127.0.0.1 port 37349%r.*%r
45*   Trying 127.0.0.1...%A* Connection refused
46* couldn't connect to host%S
47* Closing connection #0
48
49Done.
50