From 9bdb01799b6c334f1f741ea251cabf765210a0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 16 Sep 2021 14:26:18 +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 --- http-server/Service/Http.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http-server/Service/Http.php b/http-server/Service/Http.php index a2f9ef1e..92f65495 100644 --- a/http-server/Service/Http.php +++ b/http-server/Service/Http.php @@ -41,7 +41,6 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect */ public function onRequest(Request $request, Response $response): void { - $request_time_float = microtime(true); try { $node = $this->router->radix_tree($Psr7Request = ScRequest::create($request)); if (!($node instanceof Node)) { @@ -50,10 +49,11 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect if (!(($psr7Response = $node->dispatch($Psr7Request)) instanceof ResponseInterface)) { $psr7Response = $this->transferToResponse($psr7Response); } + $request_time_float = $request->server['request_time_float'] - $request->server['request_time']; + $psr7Response->withHeader('Run-Time', microtime(true) - $request_time_float); } catch (Error | \Throwable $exception) { $psr7Response = $this->exceptionHandler->emit($exception, $this->response); } finally { - $psr7Response->withHeader('Run-Time', microtime(true) - $request_time_float); $this->responseEmitter->sender($response, $psr7Response); $this->eventDispatch->dispatch(new OnAfterRequest()); }