php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66562 curl_exec returns differently than curl_multi_getcontent
Submitted: 2014-01-23 19:59 UTC Modified: -
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: nefiga at hotmail dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 5.4.24 OS: centos 6.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nefiga at hotmail dot com
New email:
PHP Version: OS:

 

 [2014-01-23 19:59 UTC] nefiga at hotmail dot com
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


Patches

multi_get_content-returns-null (last revision 2014-01-24 14:32 UTC by freeklijten at gmail dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-27 19:02 UTC] freeklijten at gmail dot com
This is an inconsistency bug and the patch I added fixes the problem. However I understood that it is probably a patch that should be applied to a new version since people may be expecting this behaviour from curl_multi_getcontent.
 [2014-04-14 01:14 UTC] stas@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-04-14 01:14 UTC] stas@php.net
-Status: Open +Status: Closed
 [2014-04-14 01:16 UTC] stas@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=54a6c1de7d621f97076eefeb82f0d50ce47f1223
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-04-15 12:04 UTC] ab@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-04-15 13:05 UTC] ab@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-04-15 13:05 UTC] ab@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=54a6c1de7d621f97076eefeb82f0d50ce47f1223
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-05-01 14:59 UTC] tyrael@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-10-07 23:15 UTC] stas@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2014-10-07 23:26 UTC] stas@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=5558d0db9b88a1975b40d4beb5db863c7d87e3c0
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 [2016-07-20 11:40 UTC] davey@php.net
Automatic comment on behalf of freek.lijten@procurios.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=54a6c1de7d621f97076eefeb82f0d50ce47f1223
Log: Fix #66562: Consistency bug where curl_multi_getcontent behaves different from curl_exec
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC