diff --git a/HttpServer/Client/Http2.php b/HttpServer/Client/Http2.php index 95c53ee5..50c5f818 100644 --- a/HttpServer/Client/Http2.php +++ b/HttpServer/Client/Http2.php @@ -24,11 +24,24 @@ class Http2 extends Component /** - * @param array $headers + * @param bool $isRecv + * @return Http2 */ - public function setHeader(array $headers) + public function setIsRecv(bool $isRecv): static + { + Context::setContext('http2isRecv', $isRecv); + return $this; + } + + + /** + * @param array $headers + * @return Http2 + */ + public function setHeader(array $headers): static { Context::setContext('http2Headers', $headers); + return $this; } @@ -125,7 +138,20 @@ class Http2 extends Component $pool->push($request, 'request.' . $method . $path); $pool->push($client, 'http2.' . $domain); }); + if (Context::getContext('http2isRecv') === false) { + return null; + } + return $this->recv($client); + } + + /** + * @param $client + * @return mixed + * @throws Exception + */ + private function recv($client): mixed + { /** @var Response $response */ $response = $client->recv(); if ($response === false || $response->statusCode > 200) { diff --git a/Kafka/Producer.php b/Kafka/Producer.php index 34ee0797..7ee183d4 100644 --- a/Kafka/Producer.php +++ b/Kafka/Producer.php @@ -40,6 +40,7 @@ class Producer extends Component /** * Producer constructor. * @param array $config + * @throws Exception */ public function __construct($config = []) {