--- /dev/null
+--TEST--\r
+Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)\r
+--SKIPIF--\r
+<?php\r
+/* unfortunately no standard function does a cast to FILE*, so we need\r
+ * curl to test this */\r
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");\r
+$handle=curl_init('http://127.0.0.1:37349/');\r
+curl_setopt($handle, CURLOPT_VERBOSE, true);\r
+curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);\r
+if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))\r
+ die("skip fopencookie not supported on this platform");\r
+--FILE--\r
+<?php\r
+function do_stuff($url) {\r
+ $handle=curl_init('http://127.0.0.1:37349/');\r
+ curl_setopt($handle, CURLOPT_VERBOSE, true);\r
+ curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);\r
+ curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));\r
+ curl_exec($handle);\r
+ echo "About to rewind!\n";\r
+ rewind($o);\r
+ echo stream_get_contents($o);\r
+ return $o;\r
+}\r
+\r
+echo "temp stream (close after):\n";\r
+fclose(do_stuff("php://temp"));\r
+\r
+echo "\nmemory stream (close after):\n";\r
+fclose(do_stuff("php://memory"));\r
+\r
+echo "\nDone.\n";\r
+--EXPECT--\r
+temp stream (close after):\r
+About to rewind!\r
+* About to connect() to 127.0.0.1 port 37349 (#0)\r
+* Trying 127.0.0.1... * Connection refused\r
+* couldn't connect to host\r
+* Closing connection #0\r
+\r
+memory stream (close after):\r
+About to rewind!\r
+* About to connect() to 127.0.0.1 port 37349 (#0)\r
+* Trying 127.0.0.1... * Connection refused\r
+* couldn't connect to host\r
+* Closing connection #0\r
+\r
+Done.\r
+--TEST--\r
+Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)\r
+--SKIPIF--\r
+<?php\r
+/* unfortunately no standard function does a cast to FILE*, so we need\r
+ * curl to test this */\r
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");\r
+$handle=curl_init('http://127.0.0.1:37349/');\r
+curl_setopt($handle, CURLOPT_VERBOSE, true);\r
+curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);\r
+if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))\r
+ die("skip fopencookie not supported on this platform");\r
+--FILE--\r
+<?php\r
+function do_stuff($url) {\r
+ $handle=curl_init('http://127.0.0.1:37349/');\r
+ curl_setopt($handle, CURLOPT_VERBOSE, true);\r
+ curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);\r
+ curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));\r
+ curl_exec($handle);\r
+ echo "About to rewind!\n";\r
+ rewind($o);\r
+ echo stream_get_contents($o);\r
+ return $o;\r
+}\r
+\r
+echo "temp stream (close after):\n";\r
+fclose(do_stuff("php://temp"));\r
+\r
+echo "\nmemory stream (close after):\n";\r
+fclose(do_stuff("php://memory"));\r
+\r
+echo "\nDone.\n";\r
+--EXPECT--\r
+temp stream (close after):\r
+About to rewind!\r
+* About to connect() to 127.0.0.1 port 37349 (#0)\r
+* Trying 127.0.0.1... * Connection refused\r
+* couldn't connect to host\r
+* Closing connection #0\r
+\r
+memory stream (close after):\r
+About to rewind!\r
+* About to connect() to 127.0.0.1 port 37349 (#0)\r
+* Trying 127.0.0.1... * Connection refused\r
+* couldn't connect to host\r
+* Closing connection #0\r
+\r
+Done.\r