Commit ef61a914 by 庄欣

CURL客户端加了超时选项

parent d0b85510
......@@ -20,6 +20,7 @@ class ControllerBase
{
public function getAuth()
{
return 3;
return request("uuid",3);
static $id;
if (!$id) {
......@@ -41,9 +42,7 @@ class ControllerBase
$uid = $this->getAuth();
$query .= "&uid=" . $uid;
}
$client->setUrl($this->prefix."?".$query);
$client->setMethod("get");
$res = $client->curl();
$res = $client->get($this->prefix."?".$query);
$res = $this->after_hook($res);
return Response::success($res);
} catch (\Exception $e) {
......
......@@ -84,6 +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 ,3);
if ($this->format == "JSON")
{
$this->header = array_merge($this->header,['Content-Type:application/json']);
......@@ -93,7 +94,9 @@ class CurlClient
curl_setopt($http,CURLOPT_POST,true);
}
curl_setopt($http,CURLOPT_HTTPHEADER,$this->header);
curl_setopt($http,CURLOPT_POSTFIELDS,$this->data);
if (!empty($this->data)) {
curl_setopt($http, CURLOPT_POSTFIELDS, $this->data);
}
/*if ($this->method === "GET") {
$NOW_TIME = time();
static $response_from_api;
......
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