From 6ffe1af6d260ce06cc0b6c24ab019f5feb728547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 24 Dec 2021 14:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AsyncClient.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/AsyncClient.php b/src/AsyncClient.php index c177957..6599924 100644 --- a/src/AsyncClient.php +++ b/src/AsyncClient.php @@ -116,6 +116,16 @@ class AsyncClient extends ClientAbstracts $this->client->send(implode("\r\n", $array) . "\r\n\r\n" . $content); $revice = $this->client->recv(); + if (!str_ends_with($revice, "\r\n\r\n")) { + while (true) { + $next = $this->client->recv(); + $revice .= $next; + if (str_ends_with($next, "\r\n\r\n")) { + break; + } + } + } + [$header, $body] = explode("\r\n\r\n", $revice); $header = explode("\r\n", $header); @@ -124,8 +134,12 @@ class AsyncClient extends ClientAbstracts $this->setStatusCode(intval(explode(' ', $status)[1])); $this->parseResponseHeaders($header); $this->setBody($body); + } + + + private function chunked() + { - var_dump($body); } @@ -139,7 +153,7 @@ class AsyncClient extends ClientAbstracts foreach ($headers as $header) { [$key, $value] = explode(': ', $header); - $array[$key] = $value; + $array[$key] = trim($value); } $this->setResponseHeader($array); }