mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 04:01:47 +00:00
Set error code and error message when there is an error; Change http error code to http status code
This commit is contained in:
+5
-5
@@ -86,10 +86,10 @@ class Curl {
|
||||
$this->curl_error_code = curl_errno($this->curl);
|
||||
$this->curl_error_message = curl_error($this->curl);
|
||||
$this->curl_error = !($this->curl_error_code === 0);
|
||||
$this->http_error_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
|
||||
$this->http_error = in_array(floor($this->http_error_code / 100), array(4, 5));
|
||||
$this->http_status_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
|
||||
$this->http_error = in_array(floor($this->http_status_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_code = $this->error ? ($this->curl_error ? $this->curl_error_code : $this->http_status_code) : 0;
|
||||
|
||||
$this->request_headers = preg_split('/\r\n/', curl_getinfo($this->curl, CURLINFO_HEADER_OUT), NULL, PREG_SPLIT_NO_EMPTY);
|
||||
$this->response_headers = '';
|
||||
@@ -102,7 +102,7 @@ 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->http_error_message = $this->error ? (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;
|
||||
@@ -126,7 +126,7 @@ class Curl {
|
||||
public $curl_error_message = NULL;
|
||||
|
||||
public $http_error = FALSE;
|
||||
public $http_error_code = NULL;
|
||||
public $http_status_code = 0;
|
||||
public $http_error_message = NULL;
|
||||
|
||||
public $request_headers = NULL;
|
||||
|
||||
Reference in New Issue
Block a user