This commit is contained in:
2023-08-12 00:02:15 +08:00
parent 8391388f1f
commit 8cce9e5a3e
+5 -6
View File
@@ -7,6 +7,7 @@ namespace Kiri\Server\Handler;
use Exception; use Exception;
use Kiri; use Kiri;
use Kiri\Core\Xml; use Kiri\Core\Xml;
use Kiri\Core\Json;
use Kiri\Di\Inject\Container; use Kiri\Di\Inject\Container;
use Kiri\Di\Context; use Kiri\Di\Context;
use Kiri\Di\Interface\ResponseEmitterInterface; use Kiri\Di\Interface\ResponseEmitterInterface;
@@ -131,12 +132,10 @@ class OnRequest implements OnRequestInterface
->withMethod($request->getMethod()); ->withMethod($request->getMethod());
$contentType = $request->header['content-type'] ?? 'application/json'; $contentType = $request->header['content-type'] ?? 'application/json';
if ($request->getContent()) { if (str_contains($contentType, 'json')) {
if (str_contains($contentType, 'json')) { $serverRequest->withParsedBody(Json::decode($request->getContent()));
$serverRequest->withParsedBody(json_decode($request->getContent(), true)); } else if (str_contains($contentType, 'xml')) {
} else if (str_contains($contentType, 'xml')) { $serverRequest->withParsedBody(Xml::toArray($request->getContent()));
$serverRequest->withParsedBody(Xml::toArray($request->getContent()));
}
} else { } else {
$serverRequest->withParsedBody($request->post ?? []); $serverRequest->withParsedBody($request->post ?? []);
} }