From 8463bc1cd891d69c0e9bca0a701c15c3ff435ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 15 Sep 2020 18:30:53 +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 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/HttpServer/Http/Response.php b/HttpServer/Http/Response.php index 9b631e14..185eb4b3 100644 --- a/HttpServer/Http/Response.php +++ b/HttpServer/Http/Response.php @@ -117,16 +117,8 @@ class Response extends Application if ($response instanceof SResponse) { $this->response = $response; } - Coroutine::defer(function () { - unset($this->response); - }); if ($this->response instanceof SResponse) { - $this->response->status($statusCode); - $this->response->header('Content-Type', $this->getContentType()); - $this->response->header('Access-Control-Allow-Origin', '*'); - $this->response->header('Run-Time', $this->getRuntime()); - $this->response->end($sendData); - return $sendData; + return $this->sendData($sendData, $statusCode); } else { return $this->printResult($sendData); } @@ -172,13 +164,17 @@ class Response extends Application } /** - * @param $response * @param $sendData * @param $status * @return mixed */ - private function sendData($response, $sendData, $status) + private function sendData($sendData, $status) { + $this->response->status($status); + $this->response->header('Content-Type', $this->getContentType()); + $this->response->header('Access-Control-Allow-Origin', '*'); + $this->response->header('Run-Time', $this->getRuntime()); + $this->response->end($sendData); return $sendData; }