Set http error message when available

This commit is contained in:
php-curl-class
2013-08-23 01:38:43 -07:00
parent 06a7470dd4
commit c3d3d301fd
+4 -1
View File
@@ -90,7 +90,6 @@ class Curl {
$this->http_error = in_array(floor($this->http_error_code / 100), array(4, 5));
$this->error = $this->curl_error || $this->http_error;
$this->error_code = $this->curl_error ? $this->curl_error_code : $this->http_error_code;
$this->error_message = $this->curl_error ? $this->curl_error_message : $this->http_error_message;
$this->request_headers = preg_split('/\r\n/', curl_getinfo($this->curl, CURLINFO_HEADER_OUT), NULL, PREG_SPLIT_NO_EMPTY);
$this->response_headers = '';
@@ -103,6 +102,9 @@ class Curl {
$this->response_headers = preg_split('/\r\n/', $this->response_headers, NULL, PREG_SPLIT_NO_EMPTY);
}
$this->http_error_message = isset($this->response_headers['0']) ? $this->response_headers['0'] : '';
$this->error_message = $this->curl_error ? $this->curl_error_message : $this->http_error_message;
return $this->error_code;
}
@@ -125,6 +127,7 @@ class Curl {
public $http_error = FALSE;
public $http_error_code = NULL;
public $http_error_message = NULL;
public $request_headers = NULL;
public $response = NULL;