Bug #66562 [NEW]: curl_exec returns differently than curl_multi_getcontent
| From: | nefiga at hotmail dot com | Date: | Thu, 23 Jan 2014 19:59:23 +0000 |
| Subject: | Bug #66562 [NEW]: curl_exec returns differently than curl_multi_getcontent | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183977@lists.php.net to get a copy of this message | ||
From: nefiga at hotmail dot com
Operating system: centos 6.4
PHP version: 5.4.24
Package: cURL related
Bug Type: Bug
Bug description:curl_exec returns differently than curl_multi_getcontent
Description:
------------
If I curl a webpage that returns standard headers and no content, using
CULOPT_RETURNTRANSFER = true to get the content returned on curl_exec, I
get an empty string in $return_value from the call
$return_value = curl_exec($url);
However, if I do the same using curl_multi functions, I get a "null"
value instead of the expected empty string.
$return_value = curl_multi_getcontent($ch);
Tested using the exact same curl options block, against two requests
(one of which returned some text, and the other which was an empty
page). The multi_curl against the empty page gives a NULL value for
$return_value, which is incorrect, and should be an empty string.
Test script:
---------------
<?php
$url = 'http://bargainlight.com/empty.php';
$url2 = 'http://bargainlight.com/nonempty.php';
$curl_options = array(
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 3,
CURLOPT_RETURNTRANSFER => true
);
$ch_1 = curl_init();
$ch_2 = curl_init();
$ch_3 = curl_init();
$ch_4 = curl_init();
curl_setopt_array($ch_1, $curl_options);
curl_setopt($ch_1, CURLOPT_URL, $url);
curl_setopt_array($ch_2, $curl_options);
curl_setopt($ch_2, CURLOPT_URL, $url);
curl_setopt_array($ch_3, $curl_options);
curl_setopt($ch_3, CURLOPT_URL, $url2);
curl_setopt_array($ch_4, $curl_options);
curl_setopt($ch_4, CURLOPT_URL, $url2);
$multi_handle = curl_multi_init();
curl_multi_add_handle($multi_handle, $ch_1);
curl_multi_add_handle($multi_handle, $ch_3);
$r2 = curl_exec($ch_2);
$r4 = curl_exec($ch_4);
do {
curl_multi_exec($multi_handle, $running);
curl_multi_select($multi_handle);
} while ($running > 0);
$r1 = curl_multi_getcontent($ch_1);
$r3 = curl_multi_getcontent($ch_3);
var_dump($r1);
var_dump($r2);
var_dump($r3);
var_dump($r4);
Expected result:
----------------
r1 should be not null
--
Edit bug report at https://bugs.php.net/bug.php?id=66562&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66562&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66562&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66562&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66562&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66562&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66562&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66562&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66562&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66562&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66562&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66562&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66562&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66562&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66562&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66562&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66562&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66562&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66562&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66562&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66562&r=mysqlcfg