2009-07-03 00:04:54 +00:00
|
|
|
--TEST--
|
|
|
|
Test curl_setopt() CURLOPT_FILE readonly file handle
|
|
|
|
--CREDITS--
|
|
|
|
Mark van der Velden
|
|
|
|
#testfest Utrecht 2009
|
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("curl")) print "skip"; ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Description : Adds a file which stores the received data from curl_exec();
|
|
|
|
* Source code : ext/curl/multi.c
|
|
|
|
* Test documentation: http://wiki.php.net/qa/temp/ext/curl
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Figure out what handler to use
|
2009-07-25 14:20:38 +00:00
|
|
|
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
|
|
|
|
if(!empty($host)) {
|
2009-07-03 00:04:54 +00:00
|
|
|
|
|
|
|
// Use the set Environment variable
|
2011-05-31 12:57:40 +00:00
|
|
|
$url = "$host/get.php?test=1";
|
2009-07-03 00:04:54 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Create a temporary file for the test
|
|
|
|
$tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
|
|
|
|
$url = 'file://'. $tempname;
|
|
|
|
|
|
|
|
// add the test data to the file
|
|
|
|
file_put_contents($tempname, "Hello World!\nHello World!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$tempfile = tempnam(sys_get_temp_dir(), 'CURL_FILE_HANDLE');
|
|
|
|
|
|
|
|
$ch = curl_init($url);
|
|
|
|
$fp = fopen($tempfile, "r"); // Opening 'fubar' with the incorrect readonly flag
|
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
|
|
curl_exec($ch);
|
|
|
|
curl_close($ch);
|
|
|
|
is_file($tempfile) and @unlink($tempfile);
|
2009-07-17 14:03:17 +00:00
|
|
|
isset($tempname) and is_file($tempname) and @unlink($tempname);
|
2009-07-03 00:04:54 +00:00
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
Warning: curl_setopt(): the provided file handle is not writable in %s on line %d
|
2009-07-25 14:20:38 +00:00
|
|
|
Hello World!
|
|
|
|
Hello World!
|