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); }