Optimized code.

This commit is contained in:
李铭昕 2019-07-11 15:51:58 +08:00
parent ea65795790
commit 7c27a5ac65
4 changed files with 15 additions and 4 deletions

View File

@ -58,7 +58,8 @@ class CoroutineHandler
if (! empty($settings)) {
$client->set($settings);
}
$client->execute($path);
$this->execute($client, $path);
$ex = $this->checkStatusCode($client, $request);
if ($ex !== true) {
return \GuzzleHttp\Promise\rejection_for($ex);
@ -69,6 +70,11 @@ class CoroutineHandler
return new FulfilledPromise($response);
}
protected function execute(Client $client, $path)
{
$client->execute($path);
}
protected function initHeaders(Client $client, RequestInterface $request, $options)
{
$headers = [];

View File

@ -71,7 +71,7 @@ class PoolHandler extends CoroutineHandler
if (! empty($settings)) {
$client->set($settings);
}
$client->execute($path);
$this->execute($client, $path);
$ex = $this->checkStatusCode($client, $request);
if ($ex !== true) {

View File

@ -63,7 +63,7 @@ class CoroutineHandler
}
$btime = microtime(true);
$client->execute($path);
$this->execute($client, $path);
$ex = $this->checkStatusCode($client, $request);
if ($ex !== true) {
@ -78,6 +78,11 @@ class CoroutineHandler
return $this->getResponse($client, $btime, $effectiveUrl);
}
protected function execute(Client $client, $path)
{
$client->execute($path);
}
protected function getSettings($options): array
{
$settings = [];

View File

@ -68,7 +68,7 @@ class PoolHandler extends CoroutineHandler
}
$btime = microtime(true);
$client->execute($path);
$this->execute($client, $path);
$ex = $this->checkStatusCode($client, $request);
if ($ex !== true) {