Bug #66562 [Com]: curl_exec returns differently than curl_multi_getcontent

From: Date: Mon, 27 Jan 2014 19:02:38 +0000
Subject: Bug #66562 [Com]: curl_exec returns differently than curl_multi_getcontent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184038@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66562&edit=1 ID: 66562 Comment by: freeklijten at gmail dot com Reported by: nefiga at hotmail dot com Summary: curl_exec returns differently than curl_multi_getcontent Status: Open Type: Bug Package: cURL related Operating System: centos 6.4 PHP Version: 5.4.24 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2014-01-23 19:59:22] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66562&edit=1

« previous php.bugs (#184038) next »