From: james dot gauth at gmail dot com
Operating system: Debian
PHP version: 4.4.4
PHP Bug Type: cURL related
Bug description: Calling curl_exec() with return transfer returns bool(true)
Description:
------------
When calling curl_exec() with the CURLOPT_RETURNTRANSFER option set to
true, a user expects that curl_exec() will return the string value of the
request.
When the URL of the request in question points to a zero-byte file,
curl_exec() returns bool(true) instead of the expected empty string.
The versions I am using are:
PHP 4.4.4 (cli) (built: Sep 11 2006 10:00:33)
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
CURL Information => libcurl/7.13.2 OpenSSL/0.9.7e zlib/1.2.3
libidn/0.5.13
Reproduce code:
---------------
<?php
// fictional URL to an existing file with no data in it (ie. 0 byte
file)
$url = 'http://www.example.com/empty_file.txt';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
// execute and return string (this should be an empty string '')
$str = curl_exec($curl);
curl_close($curl);
// the value of $str is actually bool(true), not empty string ''
var_dump($str);
?>
Expected result:
----------------
string(0) ""
Actual result:
--------------
bool(true)
--
Edit bug report at http://bugs.php.net/?id=39034&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39034&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39034&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39034&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39034&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39034&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39034&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39034&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39034&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39034&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39034&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39034&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39034&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39034&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39034&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39034&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39034&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39034&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39034&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39034&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39034&r=mysqlcfg