From 3d190ae8390d249f442309b094a053555085d866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 1 Aug 2021 16:05:55 +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 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/HttpServer/Http/Response.php b/HttpServer/Http/Response.php index 65aa3258..cc8cada6 100644 --- a/HttpServer/Http/Response.php +++ b/HttpServer/Http/Response.php @@ -165,7 +165,7 @@ class Response extends HttpService { $sendData = $this->parseData($context); $this->statusCode = $statusCode; - if (!Context::hasContext('response')) { + if (!Context::hasContext(SResponse::class)) { $this->printResult($sendData); } else { $this->sendData($sendData); @@ -217,8 +217,8 @@ class Response extends HttpService */ private function sendData($sendData): void { - $response = Context::getContext('response'); - if (!$response || !$response->isWritable()) { + $response = Context::getContext(SResponse::class); + if (!$response?->isWritable()) { return; } $this->setCookies($response); @@ -270,13 +270,11 @@ class Response extends HttpService /** - * @param null $response * @return static * @throws Exception */ - public static function create($response = null): static + public static function create(): static { - Context::setContext('response', $response); $ciResponse = Snowflake::app()->get('response'); $ciResponse->startTime = microtime(true); $ciResponse->format = self::JSON;