curl_errno возвращает 0 вместо 6

$data_struct = array(); 

$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.yahoo.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.google.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://404.php.net/', CURLOPT_RETURNTRANSFER => true);

//create the multiple cURL handle
$mh = curl_multi_init();

// create and add handles to data structure
foreach ($data_struct as $i => $data){
   $data_struct[$i]['handle'] = curl_init();
   curl_setopt_array($data_struct[$i]['handle'], $data_struct[$i]['opts']);
   curl_multi_add_handle($mh, $data_struct[$i]['handle']);
}  

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);    

} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}    

foreach ($data_struct as $i => $data){
   $row = array();
   $row['httpcode'] = curl_getinfo($data_struct[$i]['handle'] , CURLINFO_HTTP_CODE);
   $row['url'] = $data['opts'][CURLOPT_URL];
   $row['error'] = curl_error($data_struct[$i]['handle']);
   $row['errorno'] = curl_errno($data_struct[$i]['handle']);
   print_r($row);
   echo "\n";       

   curl_multi_remove_handle($mh, $data_struct[$i]['handle']);
   curl_close($data_struct[$i]['handle']);
}

output

Array
(
    [httpcode] => 302
    [url] => http://www.yahoo.com/
    [error] => 
    [errorno] => 0
)

Array
(
    [httpcode] => 302
    [url] => http://www.google.com/
    [error] => 
    [errorno] => 0
)

Array
(
    [httpcode] => 0
    [url] => http://404.php.net/
    [error] => Couldn't resolve host '404.php.net'
    [errorno] => 0
)

В той же ситуации multi curl возвращает 0 с функцией curl_errno, несмотря на то, что curl_error возвращает ошибку сообщение.

6
задан Kru 24 February 2012 в 18:07
поделиться