Commit 81419de5 by 庄欣

无反应时

parent b9c33523
......@@ -84,7 +84,7 @@ class CurlClient
curl_setopt($http,CURLOPT_URL,$this->base.$this->url);
curl_setopt($http,CURLOPT_HEADER,false);
curl_setopt($http,CURLOPT_CUSTOMREQUEST,$this->method);
curl_setopt($http,CURLOPT_TIMEOUT ,6);
curl_setopt($http,CURLOPT_TIMEOUT ,5);
if ($this->format == "JSON")
{
$this->header = array_merge($this->header,['Content-Type:application/json']);
......@@ -119,6 +119,7 @@ class CurlClient
$curlinfo = curl_getinfo($http);
//}
if ($curlinfo == false || (is_array($curlinfo) && $curlinfo['http_code'] != 200)) {
die(json_encode($curlinfo));
throw new \Exception("服务器无反应,请稍候再试");
}
$res = json_decode($res);
......
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