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 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 ?? []);
}