#48207 [Opn->Fbk]: CURLOPT_FILE behaves unexpectedly with invalid file handle
| From: | jani@php.net | Date: | Sat, 09 May 2009 19:11:35 +0000 |
| Subject: | #48207 [Opn->Fbk]: CURLOPT_FILE behaves unexpectedly with invalid file handle | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137045@lists.php.net to get a copy of this message | ||
ID: 48207
Updated by: jani@php.net
Reported By: mark at dynom dot nl
-Status: Open
+Status: Feedback
Bug Type: cURL related
Operating System: Linux
PHP Version: 5.3.0RC2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2009-05-09 14:03:57] mark at dynom dot nl
Sorry, the expected result is not 'works', it's an error being raised.
------------------------------------------------------------------------
[2009-05-09 14:01:55] mark at dynom dot nl
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 this bug report at http://bugs.php.net/?id=48207&edit=1