Commit e224b225 authored by shajiaiming's avatar shajiaiming

write into log

parent d2fc25eb
......@@ -39,6 +39,7 @@ class CurlHttpClient
protected $method;
protected $curl_handle;
protected $response;
protected $error_code;
protected $cookies = [];
const METHOD_POST = 'POST';
const METHOD_GET = 'GET';
......@@ -165,6 +166,10 @@ class CurlHttpClient
$this->post_fields = '';
curl_setopt($this->curl_handle, CURLOPT_URL, $full_url);
$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?
if (!$this->response) {
$error = 'CurlHttpClient: Could not connect to ' . $full_url;
......
......@@ -158,6 +158,9 @@ class SwooleHttpClient
$this->curl_handle->get($parts['path']);
}
$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?
if (!$this->response) {
$this->curl_handle = null;
......
......@@ -57,6 +57,8 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
*/
protected $response_;
protected $error_code;
/**
* Read timeout
*
......@@ -225,6 +227,10 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
$this->handle->set(['timeout' => $options['timeout']]);
$this->handle->post($this->uri_, $options['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?
if (!$this->response_) {
$error = 'SwooleHttpClient: Could not connect to ' . $this->scheme_ . "://" . $host . $this->uri_;
......
......@@ -76,6 +76,8 @@ class TCurlClient extends \Thrift\Transport\TTransport
*/
protected $response_;
protected $error_code;
/**
* Read timeout
*
......@@ -233,10 +235,14 @@ class TCurlClient extends \Thrift\Transport\TTransport
$this->request_ = '';
curl_setopt($this->handle, CURLOPT_URL, $full_url);
$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?
if (!$this->response_) {
$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);
$this->handle = null;
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