php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48304 curl_errno return 0 on error
Submitted: 2009-05-16 17:07 UTC Modified: 2009-05-19 14:22 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dypa at bk dot ru Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.9 OS: linux
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: dypa at bk dot ru
New email:
PHP Version: OS:

 

 [2009-05-16 17:07 UTC] dypa at bk dot ru
Description:
------------
when i use curl_multi curl_errno returns 0 on errors
see:
user@localhost:/$php code.php

this bug related to: http://bugs.php.net/bug.php?id=33570

Reproduce code:
---------------
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://404.php.net");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);

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

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$running=null;
//execute the handles
do {
    curl_multi_exec($mh,$running);
} while ($running > 0);

var_dump($ch1);
var_dump($ch2);

var_dump(curl_errno($ch1));
var_dump(curl_errno($ch2));

var_dump(curl_error($ch1));
var_dump(curl_error($ch2));

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);


Expected result:
----------------
resource(4) of type (curl)
resource(5) of type (curl)
int(6) //CURLE_COULDNT_RESOLVE_HOST (6)
int(0)
string(35) "Couldn't resolve host '404.php.net'"
string(0) ""


Actual result:
--------------
resource(4) of type (curl)
resource(5) of type (curl)
int(0)
int(0)
string(35) "Couldn't resolve host '404.php.net'"
string(0) ""


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-16 19:27 UTC] knockk at mail dot ru
same problem on windows xp php 5.2.9-1
 [2009-05-16 23:04 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-18 11:39 UTC] dypa at bk dot ru
C:\php>php test.php
resource(4) of type (curl)
resource(5) of type (curl)
int(0)
int(0)
string(51) "Could not resolve host: 404.php.net; Host not found"
string(0) ""

C:\php>php -v
PHP 5.2.10-dev (cli) (built: May 18 2009 11:46:45)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
 [2009-05-19 09:55 UTC] dypa at bk dot ru
user@ubuntu:/tmp$ uname -a
Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux

user@ubuntu:/tmp/curl-7.19.5$ ./configure
user@ubuntu:/tmp/php5.2-200905190830$ ./configure --disable-all --with-curl

user@ubuntu:/tmp$ php -v
PHP 5.2.10-dev (cli) (built: May 19 2009 12:49:30) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

user@ubuntu:/tmp$ php -i
curl
cURL support => enabled
cURL Information => libcurl/7.19.5

user@ubuntu:/tmp$ php test.php
resource(4) of type (curl)
resource(5) of type (curl)
int(0)
int(0)
string(35) "Couldn't resolve host '404.php.net'"
string(0) ""
 [2009-05-19 14:22 UTC] jani@php.net
Actually you should be using this: http://php.net/curl_multi_info_read
The multi API is "special" and the easy API functions don't always work fine in every case. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC