This commit is contained in:
2021-05-11 11:10:38 +08:00
parent 0592f2b50f
commit 5ea604651b
3 changed files with 4 additions and 12 deletions
+1 -3
View File
@@ -136,9 +136,7 @@ class Curl extends ClientAbstracts
*/
private function execute($curl): Result|bool|array|string
{
defer(function () {
$this->cleanData();
});
defer(fn() => $this->cleanData());
$output = curl_exec($curl);
if ($output === false) {
return $this->fail(400, curl_error($curl));
+2 -6
View File
@@ -185,9 +185,7 @@ class Http2 extends Component
$request->headers = array_merge($request->headers, [
'Host' => $domain
]);
defer(function () use ($domain, $path, $request, $method) {
$this->channel->push($request, 'request.' . $method . $path);
});
defer(fn() => $this->channel->push($request, 'request.' . $method . $path));
return $this->doRequest($request, $domain, $isSsl, $timeout);
}
@@ -217,9 +215,7 @@ class Http2 extends Component
private function doRequest(Request $request, $domain, $ssl, $timeout): mixed
{
$client = $this->getClient($domain, $ssl, $timeout);
defer(function () use ($client, $domain) {
$this->channel->push($client, 'http2.' . $domain);
});
defer(fn() => $this->channel->push($client, 'http2.' . $domain));
$client->send($request);
if (Context::getContext('http2isRecv') === false) {
return null;
+1 -3
View File
@@ -50,9 +50,7 @@ class Client extends Component
if ($isSend === false) {
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
}
defer(function () {
$this->clientRecover();
});
defer(fn() => $this->clientRecover());
if (is_bool($unpack = Json::decode($this->client->recv()))) {
$unpack = $this->addError('Service return data format error(500)');
}