protected function parseBody(string $resource, string $type, string $body)
    {
        $content_type = static::parseContentType($type);
        $mime = $content_type['mime'] ?? $content_type;

        if (($content_type['charset'] ?? null) !== null) {
            $body = mb_convert_encoding(
                $body,
                'UTF-8',
                $content_type['charset']
            );
        }

        if ($mime === '') {
            if ($body === '') {
                return [];
            }
        } elseif ($mime === 'application/json') {
            $data = json_decode($body, true);
            if (!empty($data)) {
                return [
                    'mime' => $mime,
                    'data' => $data,
                ];
            }
        } else {
            if (!$this->safe_method) {
                $handlers = $this->resources[$resource]['handlers'] ?? [];
                if (!empty($handlers)) {
                    $handlers = $handlers[$this->method] ?? null;
                    if (is_array($handlers)
                        && array_key_exists($mime, $handlers)
                    ) {
                        return [
                            'mime' => $mime,
                            'body' => $body,
                        ];
                    }
                }
            }

            $this->sendError(
                static::ERROR_UNSUPPORTED_MEDIA_TYPE,
                "Media-Type '$mime' is not supported"
            );
        }

        $this->sendError(
            static::ERROR_INVALID_PAYLOAD,
            "Body payload could not be parsed"
        );
    }