Icicle\Http\Server\Server::createResponse PHP Method

createResponse() private method

private createResponse ( Request $request, Icicle\Socket\Socket $socket ) : Generator
$request Request
$socket Icicle\Socket\Socket
return Generator
    private function createResponse(Request $request, Socket $socket) : \Generator
    {
        try {
            assert(yield from $this->log->log(Log::DEBUG, 'Received request from %s:%d for %s', $socket->getRemoteAddress(), $socket->getRemotePort(), $request->getUri()));
            $response = $this->handler->onRequest($request, $socket);
            if ($response instanceof \Generator) {
                $response = (yield from $response);
            } elseif ($response instanceof Awaitable) {
                $response = (yield $response);
            }
            if (!$response instanceof Response) {
                throw new InvalidResultError(sprintf('A %s object was not returned from %::onRequest().', Response::class, get_class($this->handler)), $response);
            }
        } catch (Throwable $exception) {
            yield from $this->log->log(Log::ERROR, "Uncaught exception when creating response to a request from %s:%d on %s:%d in file %s on line %d: %s", $socket->getRemoteAddress(), $socket->getRemotePort(), $socket->getLocalAddress(), $socket->getLocalPort(), $exception->getFile(), $exception->getLine(), $exception->getMessage());
            $response = (yield from $this->createDefaultErrorResponse(500));
        }
        return $response;
    }