From 28a920841a7695865c093cd70026de57ba5cef59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 17 Sep 2020 14:26:38 +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 --- HttpServer/Http/Response.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/HttpServer/Http/Response.php b/HttpServer/Http/Response.php index f4b67e2e..207e0e12 100644 --- a/HttpServer/Http/Response.php +++ b/HttpServer/Http/Response.php @@ -98,13 +98,12 @@ class Response extends Application /** * @param $key * @param $value + * @return Response */ public function addHeader($key, $value) { - if ($this->isClient()) { - return; - } - $this->response->header($key, $value); + $this->headers[$key] = $value; + return $this; } /** @@ -184,6 +183,12 @@ class Response extends Application $this->response->status($status); $this->response->header('Content-Type', $this->getContentType()); $this->response->header('Run-Time', $this->getRuntime()); + if (!empty($this->headers)) { + foreach ($this->headers as $key => $header) { + $this->response->header($key, $header); + } + $this->headers = []; + } if (empty($sendData)) { $sendData = ''; }