Swoole\Protocol\HttpServer::processDynamic PHP Method

processDynamic() public method

处理动态请求
public processDynamic ( Request $request, Response $response )
$request Swoole\Request
$response Swoole\Response
    function processDynamic(Swoole\Request $request, Swoole\Response $response)
    {
        $path = $this->document_root . '/' . $request->meta['path'];
        if (is_file($path)) {
            $response->head['Content-Type'] = 'text/html';
            ob_start();
            try {
                include $path;
                $response->body = ob_get_contents();
            } catch (\Exception $e) {
                $response->setHttpStatus(500);
                $response->body = $e->getMessage() . '!<br /><h1>' . self::SOFTWARE . '</h1>';
            }
            ob_end_clean();
        } else {
            $this->httpError(404, $response, "页面不存在({$request->meta['path']})!");
        }
    }