From d047b1db2d5f178c199138d07c15e5fbf1d6e871 Mon Sep 17 00:00:00 2001 From: Denis Kiselev Date: Tue, 9 Feb 2021 15:17:40 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=BA=20=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=B5=D1=82=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C,=20=D1=82=D0=BE=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D0=BD=D0=B0=D0=B4=D0=BE=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Может случиться так, что в методе request() ответ уже будет прочитан (например, для записи в лог по шаблону {res_body}, если клиент будет инициализирован соответствующе). В итоге без возврата указателя в начало, $response->getBody()->getContents() вернут пустой результат. --- src/Client.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index eff06b2..31e6e56 100644 --- a/src/Client.php +++ b/src/Client.php @@ -121,7 +121,11 @@ private function send(string $method, string $url, array $data = []): array { $authParams = ['auth' => [$this->login, $this->password], 'json' => $data]; $response = $this->client->request($method, $url, $authParams); + $stream = $response->getBody(); + if ($stream->isSeekable()) { + $stream->seek(0); + } - return json_decode($response->getBody()->getContents(), true); + return json_decode($stream->getContents(), true); } }