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 private function execute($curl): Result|bool|array|string
{ {
defer(function () { defer(fn() => $this->cleanData());
$this->cleanData();
});
$output = curl_exec($curl); $output = curl_exec($curl);
if ($output === false) { if ($output === false) {
return $this->fail(400, curl_error($curl)); 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, [ $request->headers = array_merge($request->headers, [
'Host' => $domain 'Host' => $domain
]); ]);
defer(function () use ($domain, $path, $request, $method) { defer(fn() => $this->channel->push($request, 'request.' . $method . $path));
$this->channel->push($request, 'request.' . $method . $path);
});
return $this->doRequest($request, $domain, $isSsl, $timeout); return $this->doRequest($request, $domain, $isSsl, $timeout);
} }
@@ -217,9 +215,7 @@ class Http2 extends Component
private function doRequest(Request $request, $domain, $ssl, $timeout): mixed private function doRequest(Request $request, $domain, $ssl, $timeout): mixed
{ {
$client = $this->getClient($domain, $ssl, $timeout); $client = $this->getClient($domain, $ssl, $timeout);
defer(function () use ($client, $domain) { defer(fn() => $this->channel->push($client, 'http2.' . $domain));
$this->channel->push($client, 'http2.' . $domain);
});
$client->send($request); $client->send($request);
if (Context::getContext('http2isRecv') === false) { if (Context::getContext('http2isRecv') === false) {
return null; return null;
+1 -3
View File
@@ -50,9 +50,7 @@ class Client extends Component
if ($isSend === false) { if ($isSend === false) {
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')'); return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
} }
defer(function () { defer(fn() => $this->clientRecover());
$this->clientRecover();
});
if (is_bool($unpack = Json::decode($this->client->recv()))) { if (is_bool($unpack = Json::decode($this->client->recv()))) {
$unpack = $this->addError('Service return data format error(500)'); $unpack = $this->addError('Service return data format error(500)');
} }