This commit is contained in:
2021-11-29 11:50:28 +08:00
parent 336237d338
commit af9b88f114
3 changed files with 26 additions and 0 deletions
+24
View File
@@ -49,6 +49,9 @@ abstract class ClientAbstracts implements IClient
private array $_responseHeader = [];
private int $statusCode = 200;
@@ -63,6 +66,9 @@ abstract class ClientAbstracts implements IClient
private int $connect_timeout = 1;
/**
* @var resource|\Swoole\Coroutine\Http\Client
*/
protected mixed $client;
@@ -75,6 +81,24 @@ abstract class ClientAbstracts implements IClient
}
/**
* @return array
*/
public function getResponseHeader(): array
{
return $this->_responseHeader;
}
/**
* @param array $responseHeader
*/
public function setResponseHeader(array $responseHeader): void
{
$this->_responseHeader = $responseHeader;
}
/**
* @param int $statusCode
*/
+1
View File
@@ -53,6 +53,7 @@ class CoroutineClient extends ClientAbstracts
}
$this->setStatusCode($this->client->getStatusCode());
$this->setBody($this->client->getBody());
$this->setResponseHeader($this->client->headers);
} catch (\Throwable $exception) {
Kiri::getDi()->get(Logger::class)->error('rpc', [$exception]);
$this->setStatusCode(-1);
+1
View File
@@ -172,6 +172,7 @@ class Curl extends ClientAbstracts
$this->setStatusCode(intval($status[1]));
$this->setBody($body);
$this->setResponseHeader($header);
}
/**