#42300 [NEW]: curl_copy_handle use curl_multi_exec get nothing.
| From: | foxgoblin at gmail dot com | Date: | Tue, 14 Aug 2007 18:57:22 +0000 |
| Subject: | #42300 [NEW]: curl_copy_handle use curl_multi_exec get nothing. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-116056@lists.php.net to get a copy of this message | ||
From: foxgoblin at gmail dot com
Operating system: windows xp
PHP version: 5CVS-2007-08-14 (snap)
PHP Bug Type: cURL related
Bug description: curl_copy_handle use curl_multi_exec get nothing.
Description:
------------
use curl_copy_handle copy the curl handle, add in curl multi handle,
curl_multi_exec return nothing.
Reproduce code:
---------------
<?
function getMultiCUrlContent($chs){
$contents = array();
$mh = curl_multi_init();
foreach($chs as $key => $ch){
curl_multi_add_handle($mh,$ch);
}
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active and $mrc == CURLM_OK) {
// wait for network
if (curl_multi_select($mh) != -1) {
// pull in any new data, or at least handle timeouts
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
if ($mrc != CURLM_OK) {
echo "[".date("Y-m-d H:i:s")."]\t[getMultiCUrlContent
error]\t".$mrc."\n";
}
foreach($chs as $key => $ch){
if(curl_errno($ch) == CURLE_OK){
$contents[$key]= curl_multi_getcontent($ch);
}
else{
echo "[".date("Y-m-d H:i:s")."]\t[get content
error]\t".curl_error($ch)."\n";
}
}
curl_multi_close($mh);
return $contents;
}
$chs = array();
$ch = curl_init("http://www.google.com/");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$chs[] = $ch;
$ch = curl_copy_handle($ch);
$chs[] = $ch;
$contents = getMultiCUrlContent($chs);
print_r($contents);
?>
Expected result:
----------------
Array
(
[0] => <html><head><meta http-equiv="content-type"
content="text/html;
charset=ISO-8859-1"><title>Google</title>...
[1] => <html><head><meta http-equiv="content-type"
content="text/html;
charset=ISO-8859-1"><title>Google</title>...
)
Actual result:
--------------
Array
(
[0] => <html><head><meta http-equiv="content-type"
content="text/html;
charset=ISO-8859-1"><title>Google</title>...
[1] =>
)
--
Edit bug report at http://bugs.php.net/?id=42300&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42300&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42300&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42300&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42300&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42300&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42300&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42300&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42300&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42300&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42300&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42300&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42300&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42300&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42300&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42300&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42300&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42300&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42300&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42300&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42300&r=mysqlcfg