Commit d2609684 authored by shajiaiming's avatar shajiaiming

Merge branch 'TRADE-169' of gitlab.33.cn:_site-res/system

parents 91c88b8a e224b225
...@@ -39,6 +39,7 @@ class CurlHttpClient ...@@ -39,6 +39,7 @@ class CurlHttpClient
protected $method; protected $method;
protected $curl_handle; protected $curl_handle;
protected $response; protected $response;
protected $error_code;
protected $cookies = []; protected $cookies = [];
const METHOD_POST = 'POST'; const METHOD_POST = 'POST';
const METHOD_GET = 'GET'; const METHOD_GET = 'GET';
...@@ -165,6 +166,10 @@ class CurlHttpClient ...@@ -165,6 +166,10 @@ class CurlHttpClient
$this->post_fields = ''; $this->post_fields = '';
curl_setopt($this->curl_handle, CURLOPT_URL, $full_url); curl_setopt($this->curl_handle, CURLOPT_URL, $full_url);
$this->response = curl_exec($this->curl_handle); $this->response = curl_exec($this->curl_handle);
$this->error_code = curl_errno($this->curl_handle);
if(200 !== $this->error_code){
\Yii::$app->fpf->error('http', curl_error($this->curl_handle), __CLASS__, __FUNCTION__, ' ERROR_CODE:' .$this->error_code);
}
// Connect failed? // Connect failed?
if (!$this->response) { if (!$this->response) {
$error = 'CurlHttpClient: Could not connect to ' . $full_url; $error = 'CurlHttpClient: Could not connect to ' . $full_url;
......
...@@ -158,6 +158,9 @@ class SwooleHttpClient ...@@ -158,6 +158,9 @@ class SwooleHttpClient
$this->curl_handle->get($parts['path']); $this->curl_handle->get($parts['path']);
} }
$this->response = $this->curl_handle->body; $this->response = $this->curl_handle->body;
if(200 !== $this->curl_handle->errCode){
\Yii::$app->fpf->error('http', $this->curl_handle->errCode, __CLASS__, __FUNCTION__, ' ERROR_CODE:' .$this->curl_handle->errCode);
}
// Connect failed? // Connect failed?
if (!$this->response) { if (!$this->response) {
$this->curl_handle = null; $this->curl_handle = null;
......
...@@ -57,6 +57,8 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport ...@@ -57,6 +57,8 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
*/ */
protected $response_; protected $response_;
protected $error_code;
/** /**
* Read timeout * Read timeout
* *
...@@ -225,6 +227,10 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport ...@@ -225,6 +227,10 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
$this->handle->set(['timeout' => $options['timeout']]); $this->handle->set(['timeout' => $options['timeout']]);
$this->handle->post($this->uri_, $options['body']); $this->handle->post($this->uri_, $options['body']);
$this->response_ = $this->handle->body; $this->response_ = $this->handle->body;
if(200 !== $this->handle->errCode){
\Yii::$app->fpf->error('http', $this->handle->errCode, __CLASS__, __FUNCTION__, ' ERROR_CODE:' .$this->handle->errCode);
}
// Connect failed? // Connect failed?
if (!$this->response_) { if (!$this->response_) {
$error = 'SwooleHttpClient: Could not connect to ' . $this->scheme_ . "://" . $host . $this->uri_; $error = 'SwooleHttpClient: Could not connect to ' . $this->scheme_ . "://" . $host . $this->uri_;
......
...@@ -76,6 +76,8 @@ class TCurlClient extends \Thrift\Transport\TTransport ...@@ -76,6 +76,8 @@ class TCurlClient extends \Thrift\Transport\TTransport
*/ */
protected $response_; protected $response_;
protected $error_code;
/** /**
* Read timeout * Read timeout
* *
...@@ -233,10 +235,14 @@ class TCurlClient extends \Thrift\Transport\TTransport ...@@ -233,10 +235,14 @@ class TCurlClient extends \Thrift\Transport\TTransport
$this->request_ = ''; $this->request_ = '';
curl_setopt($this->handle, CURLOPT_URL, $full_url); curl_setopt($this->handle, CURLOPT_URL, $full_url);
$this->response_ = curl_exec($this->handle); $this->response_ = curl_exec($this->handle);
$this->error_code = curl_errno($this->handle);
if(200 !== $this->error_code){
\Yii::$app->fpf->error('http', curl_error($this->handle), __CLASS__, __FUNCTION__, ' ERROR_CODE:' .$this->error_code);
}
// Connect failed? // Connect failed?
if (!$this->response_) { if (!$this->response_) {
$error = 'TCurlClient: Could not connect to ' . $full_url; $error = 'TCurlClient: Could not connect to ' . $full_url;
\Yii::$app->fpf->error('http', curl_errno($this->handle), __CLASS__, __FUNCTION__, ' ERROR:' .$error); \Yii::$app->fpf->error('http', curl_error($this->handle), __CLASS__, __FUNCTION__, ' ERROR:' .$error);
curl_close($this->handle); curl_close($this->handle);
$this->handle = null; $this->handle = null;
throw new TTransportException($error, TTransportException::NOT_OPEN); throw new TTransportException($error, TTransportException::NOT_OPEN);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment