From 4f99ec5756ea06e9b265968c3bc597cf841a5f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 24 Dec 2021 14:19:20 +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 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/AsyncClient.php b/src/AsyncClient.php index b785aa5..66ed762 100644 --- a/src/AsyncClient.php +++ b/src/AsyncClient.php @@ -122,9 +122,7 @@ class AsyncClient extends ClientAbstracts $status = array_shift($header); $this->setStatusCode(intval(explode(' ', $status)[1])); - $this->setResponseHeader($header); - - var_dump($this->getResponseHeaders()); + $this->parseResponseHeaders($header); if ($this->getResponseHeader('Transfer-Encoding') == 'chunked') { $explode = explode("\r\n\r\n", str_replace("0\r\n\r\n", '', $body)); @@ -141,6 +139,22 @@ class AsyncClient extends ClientAbstracts } + /** + * @param array $headers + * @return void + */ + private function parseResponseHeaders(array $headers) + { + $array = []; + foreach ($headers as $header) { + [$key, $value] = explode(': ', $header); + + $array[$key] = $value; + } + $this->setResponseHeader($array); + } + + /** * @param $path * @param $data