From: mark at dynom dot nl Operating system: Linux PHP version: 5.3.0RC2 PHP Bug Type: cURL related Bug description: CURLOPT_FILE behaves unexpectedly with invalid file handle
Description: ------------ The option 'CURLOPT_FILE' takes a file handle as argument, however when you open the file read-only. cURL *silently* fails and downloads only 1 successful iteration of data. This *only* happens when CURLOPT_RETURNTRANSFER is not defined, since that disables the 'CURLOPT_FILE' feature. It's expected that some sort of warning/error is raised, just like when a write flag is set when the file is not writable. When the latter happens, cURL falls back on CURLOPT_RETURNTRANSFER = false. Reproduce code: --------------- <?php error_reporting( E_ALL ); $ch = curl_init('http://kernel.org/pub/linux/kernel/v1.0/linux-1.0.tar.bz2'); $fp = fopen("/tmp/fubar", "r"); // Opening 'fubar' with the incorrect readonly flag curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); // Debug $info = curl_getinfo($ch); if ($info['size_download'] !== $info["download_content_length"]) { echo 'fail'; } else { echo 'works'; } curl_close($ch); Expected result: ---------------- works Actual result: -------------- fail -- Edit bug report at http://bugs.php.net/?id=48207&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48207&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48207&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48207&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48207&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48207&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48207&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48207&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48207&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48207&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48207&r=support Expected behavior: http://bugs.php.net/fix.php?id=48207&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48207&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48207&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48207&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48207&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48207&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48207&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48207&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48207&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48207&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48207&r=mysqlcfg