From 8cce9e5a3e59821a6bbe5fb2f9c9deba795df66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sat, 12 Aug 2023 00:02:15 +0800 Subject: [PATCH] qqq --- Handler/OnRequest.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Handler/OnRequest.php b/Handler/OnRequest.php index 5c8d4c7..3b26c5e 100644 --- a/Handler/OnRequest.php +++ b/Handler/OnRequest.php @@ -7,6 +7,7 @@ namespace Kiri\Server\Handler; use Exception; use Kiri; use Kiri\Core\Xml; +use Kiri\Core\Json; use Kiri\Di\Inject\Container; use Kiri\Di\Context; use Kiri\Di\Interface\ResponseEmitterInterface; @@ -131,12 +132,10 @@ class OnRequest implements OnRequestInterface ->withMethod($request->getMethod()); $contentType = $request->header['content-type'] ?? 'application/json'; - if ($request->getContent()) { - if (str_contains($contentType, 'json')) { - $serverRequest->withParsedBody(json_decode($request->getContent(), true)); - } else if (str_contains($contentType, 'xml')) { - $serverRequest->withParsedBody(Xml::toArray($request->getContent())); - } + if (str_contains($contentType, 'json')) { + $serverRequest->withParsedBody(Json::decode($request->getContent())); + } else if (str_contains($contentType, 'xml')) { + $serverRequest->withParsedBody(Xml::toArray($request->getContent())); } else { $serverRequest->withParsedBody($request->post ?? []); }