1--TEST--
2Test curl option CURLOPT_WRITEFUNCTION
3--CREDITS--
4Mathieu Kooiman <mathieuk@gmail.com>
5Dutch UG, TestFest 2009, Utrecht
6--DESCRIPTION--
7Writes the value 'test' to a temporary file. Use curl to access this file, passing the output into a callback. Tests the PHP_CURL_USER case in curl_write.
8--SKIPIF--
9<?php if (!extension_loaded("curl")) print "skip"; ?>
10--FILE--
11<?php
12
13function curl_callback($curl_handle, $received_data)
14{
15	echo $received_data;
16	return strlen($received_data);
17}
18
19$log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
20
21$fp = fopen($log_file, 'w+');
22fwrite($fp, "test");
23fclose($fp);
24
25$ch = curl_init();
26curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'curl_callback');
27curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
28curl_exec($ch);
29curl_close($ch);
30
31// cleanup
32unlink($log_file);
33
34?>
35--EXPECT--
36test
37