From 62a626aec3811f5ee373f74715f6c331a77cdba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 25 Feb 2021 14:53: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/Events/OnRequest.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index 5d2b6858..5ffd96b0 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -40,12 +40,11 @@ class OnRequest extends Callback fire(Event::SYSTEM_RESOURCE_RELEASES); }); [$request, $response] = static::create($request, $response); - if ($request->is('favicon.ico')) { - return \send(null, 404); + if (!$request->is('favicon.ico')) { + return \router()->dispatch(); } - return \router()->dispatch(); + return \send(null); } catch (ExitException | Error | \Throwable $exception) { - $this->addError($exception); if ($exception instanceof ExitException) { return \send($exception->getMessage(), $exception->getCode()); } @@ -77,11 +76,10 @@ class OnRequest extends Callback */ protected function sendErrorMessage($sRequest, $sResponse, $exception): bool|string { + $this->error($exception); $params = Snowflake::app()->getLogger()->exception($exception); if ($sResponse instanceof Response) { - $sResponse->header('Access-Control-Allow-Origin', '*'); - $sResponse->status(200); - return $sResponse->end($params); + [$sRequest, $sResponse] = [HRequest::create($sRequest), HResponse::create($sResponse)]; } $sResponse->addHeader('Access-Control-Allow-Origin', '*');