PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_Curl » Bug #2562

Net_Curl isn't able to determine status code

Details

Request #2562Net_Curl isn't able to determine status code
Submitted2004-10-18 16:26 UTC
Fromrobin dot ericsson at profecta dot se
StatusClosed
PackageNet_Curl
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2004-10-18 16:26 UTC] robin dot ericsson at profecta dot se

Description:
------------
Net_Curl isn't able to determine whether the current url resultet in 200 OK or error of some kind. Using the attached patch Net_Curl throws and PEAR_Error if status-code is something else that 2XX. (Maybe this could be changed to something else, but atleast the general idea is here.

Reproduce code:
---------------
--- Curl.php.old 2004-09-09 16:08:19.304143936 +0200
+++ Curl.php 2004-09-09 16:15:25.000428264 +0200
@@ -421,12 +421,18 @@


$ret = curl_exec($ch);
+ $info = curl_getinfo($ch);
+ $http_code = (string) $info['http_code'];
if (!$ret) {
$errObj = new PEAR_Error(curl_error($ch), curl_errno($ch));
$this->error =& $errObj;
return($errObj);
+ } else if ($http_code != '' && $http_code{0} != '2') {
+ $errObj = new PEAR_Error('Unexpected HTTP-code found: '.$info['http_code']);
+ $this->error =& $errObj;
+ return($errObj);
}
-
+
return($ret);
}

Expected result:
----------------
To get some sort of error when page return other than 200 OK

[2005-07-13 21:56 UTC] joe at joestump dot net

Fixed in my Net_Curl patches:

http://zebulon.miester.org/~jstump/pear/Net_Curl/