From 216363d8a795240afea6962f24e24e55ab598a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 30 Aug 2021 15:24:31 +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 --- http-server/Message/Message.php | 5 +---- http-server/Message/Response.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/http-server/Message/Message.php b/http-server/Message/Message.php index 10f447c7..9a4e4bd9 100644 --- a/http-server/Message/Message.php +++ b/http-server/Message/Message.php @@ -177,10 +177,7 @@ trait Message */ private function addRequestHeader($key, $value) { - $this->headers[$key] = []; - foreach (explode(';', $value) as $item) { - $this->headers[$key][] = $item; - } + $this->headers[$key] = [$value]; } diff --git a/http-server/Message/Response.php b/http-server/Message/Response.php index 9806bed3..91fece63 100644 --- a/http-server/Message/Response.php +++ b/http-server/Message/Response.php @@ -2,6 +2,8 @@ namespace Server\Message; +use Exception; +use JetBrains\PhpStorm\Pure; use Psr\Http\Message\ResponseInterface; @@ -26,23 +28,24 @@ class Response implements ResponseInterface, \Server\ResponseInterface /** * */ - public function __construct() + #[Pure] public function __construct() { $this->stream = new Stream(''); } - /** - * @param string $type - * @return $this - */ + /** + * @param string $type + * @return $this + * @throws Exception + */ public function withContentType(string $type): static { if (!in_array($type, [ Response::CONTENT_TYPE_HTML, Response::CONTENT_TYPE_JSON, Response::CONTENT_TYPE_STREAM, Response::CONTENT_TYPE_XML ])) { - throw new \Exception('Wrong content type.'); + throw new Exception('Wrong content type.'); } return $this->withHeader('Content-Type', $type); }