public function handleServerRequest(ServerRequestInterface $request): array
    {
        $messages = [];

        try {
            $body = $request->getBody()->getContents();
            $uriPath = $request->getUri()->getPath();

            if ('/favicon.ico' === $uriPath) {
                return [$this->createFaviconResponse(), []];
            }

            $from = microtime(true);
            $method = $request->getMethod();
            $headers = $request->getHeaders();

            $symfonyRequest = new Request(
                $request->getQueryParams(),
                $request->getParsedBody() ?? [],
                $request->getAttributes(),
                $request->getCookieParams(),
                $request->getUploadedFiles(),
                [], // Server is partially filled a few lines below
                $body
            );

            $symfonyRequest->setMethod($method);
            $symfonyRequest->headers->replace($headers);
            $symfonyRequest->server->set('REQUEST_URI', $uriPath);
            if (isset($headers['Host'])) {
                $symfonyRequest->server->set('SERVER_NAME', explode(':', $headers['Host'][0]));
            }

            $symfonyResponse = $this->kernel->handle($symfonyRequest);
            $this->kernel->terminate($symfonyRequest, $symfonyResponse);
            $to = microtime(true);
            $messages[] = new ConsoleMessage(
                $request->getUri()->getPath(),
                $method,
                $symfonyResponse->getStatusCode(),
                $symfonyResponse->getContent(),
                \intval(($to - $from) * 1000)
            );

            $this->applyResponseEncoding(
                $symfonyRequest,
                $symfonyResponse
            );

            $httpResponse = new \React\Http\Response(
                $symfonyResponse->getStatusCode(),
                $symfonyResponse->headers->all(),
                $symfonyResponse->getContent()
            );

            $symfonyRequest = null;
            $symfonyResponse = null;

            /*
             * Catching errors and sending to syslog.
             */
        } catch (\Throwable $exception) {
            $messages[] = new ConsoleException($exception);
            $httpResponse = new \React\Http\Response(
                400,
                ['Content-Type' => 'text/plain'],
                $exception->getMessage()
            );
        }

        return [$httpResponse, $messages];
    }