更新 Http.php

This commit is contained in:
2019-06-26 18:54:48 +08:00
committed by Gitee
parent 58b185bbb7
commit 366e995149
+6 -9
View File
@@ -27,12 +27,10 @@ class Http
) { ) {
return $this->curl($url, $pushType, $data, $callback, $isSSL); return $this->curl($url, $pushType, $data, $callback, $isSSL);
} }
if (!extension_loaded('swoole')) {
return $this->curl($url, $pushType, $data, $callback, $isSSL);
} else {
$url = 'https://' . $this->url . '/' . $url; $url = 'https://' . $this->url . '/' . $url;
return $this->coroutine($url, $pushType, $data, $callback, $isSSL);
} return $this->curl($url, $pushType, $data, $callback, $isSSL);
} }
/** /**
@@ -144,7 +142,9 @@ class Http
private function build($body, $callback, $_data) private function build($body, $callback, $_data)
{ {
$result = []; $result = [];
if ($callback === NULL) { if ($callback !== NULL) {
return call_user_func($callback, $body, $_data);
}
if (is_null($results = json_decode($body, TRUE))) { if (is_null($results = json_decode($body, TRUE))) {
$data = simplexml_load_string($body, 'SimpleXMLElement', LIBXML_NOCDATA); $data = simplexml_load_string($body, 'SimpleXMLElement', LIBXML_NOCDATA);
$results = json_decode(json_encode($data), TRUE); $results = json_decode(json_encode($data), TRUE);
@@ -160,9 +160,6 @@ class Http
$result['message'] = 'system success.'; $result['message'] = 'system success.';
$result['data'] = $results; $result['data'] = $results;
} }
} else {
$result = call_user_func($callback, $body, $_data);
}
if (!is_array($result)) { if (!is_array($result)) {
return $result; return $result;
} }