#42300 [Opn-Fbk]: curl_copy_handle use curl_multi_exec get nothing.

2007-11-16 Thread jani
 ID:   42300
 Updated by:   [EMAIL PROTECTED]
 Reported By:  foxgoblin at gmail dot com
-Status:   Open
+Status:   Feedback
 Bug Type: cURL related
 Operating System: windows xp
 PHP Version:  5CVS-2007-08-14 (snap)
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi




Previous Comments:


[2007-10-18 17:38:27] foxgoblin at gmail dot com

I try php/5.2.0 , it's ok!

it build php_curl with libcurl/7.14.0

cURL Information = libcurl/7.14.0 OpenSSL/0.9.8d zlib/1.2.3



[2007-10-18 17:33:45] foxgoblin at gmail dot com

cURL Information = libcurl/7.16.0 OpenSSL/0.9.8e zlib/1.2.3

I use php.net distribute Windows Binaries php-5.2.4, it build php_curl
extension with libcurl/7.16.0 .



[2007-10-13 13:19:07] [EMAIL PROTECTED]

Your code works just fine for me with PHP 5.3-dev and libcurl 7.17.0. 
Which version of libcurl are you using?  Does upgrading the a more
recent version help?



[2007-08-14 18:57:22] foxgoblin at gmail dot com

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] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
[1] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
)

Actual result:
--
Array
(
[0] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
[1] = 
)





-- 
Edit this bug report at http://bugs.php.net/?id=42300edit=1


#42300 [Opn-Fbk]: curl_copy_handle use curl_multi_exec get nothing.

2007-10-13 Thread mj
 ID:   42300
 Updated by:   [EMAIL PROTECTED]
 Reported By:  foxgoblin at gmail dot com
-Status:   Open
+Status:   Feedback
 Bug Type: cURL related
 Operating System: windows xp
 PHP Version:  5CVS-2007-08-14 (snap)
 New Comment:

Your code works just fine for me with PHP 5.3-dev and libcurl 7.17.0. 
Which version of libcurl are you using?  Does upgrading the a more
recent version help?


Previous Comments:


[2007-08-14 18:57:22] foxgoblin at gmail dot com

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] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
[1] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
)

Actual result:
--
Array
(
[0] = htmlheadmeta http-equiv=content-type
content=text/html; charset=ISO-8859-1titleGoogle/title...
[1] = 
)





-- 
Edit this bug report at http://bugs.php.net/?id=42300edit=1