public function onRequest(Request $request, Response $response)
    {
        // Compat fpm server
        $this->_compatFPM($request);

        // 注入全局变量
        $GLOBALS['__$response'] = $response;

        $response->header('Server', 'ePHP/'. $this->version);

        $filename = APP_PATH . '/public'. $_SERVER['PATH_INFO'];

        // !in_array($extname, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico'])
        // Try files, otherwise route to app
        if ( !is_file($filename) ) {
            ob_start();
            (new \ePHP\Core\Application())->run();
            $h = ob_get_clean();

            // Fixed output o byte
            // if (strlen($h) === 0) {
            //     $h = ' ';
            // }

            $response->end($h);
        } else {
            $extname = substr($filename, strrpos($filename, '.') + 1);
            if ( isset( $this->contentType[$extname] ) ) {
                $response->header('Content-Type', $this->contentType[$extname]);
            }
            $response->sendfile($filename);
        }

        // 非调试模式，打印访问日志
        $this->printAccessLog();
    }
public function onRequest(Request $request, Response $response)
    {
        // Compat fpm server
        $this->_compatFPM($request);

        // 注入全局变量
        $GLOBALS['__$response'] = $response;

        $response->header('Server', 'ePHP/'. $this->version);

        $filename = APP_PATH . '/public'. $_SERVER['PATH_INFO'];

        // !in_array($extname, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico'])
        // Try files, otherwise route to app
        if ( !is_file($filename) ) {
            ob_start();
            (new \ePHP\Core\Application())->run();
            $h = ob_get_clean();

            // Fixed output o byte
            // if (strlen($h) === 0) {
            //     $h = ' ';
            // }

            $response->end($h);
        } else {
            $extname = substr($filename, strrpos($filename, '.') + 1);
            if ( isset( $this->contentType[$extname] ) ) {
                $response->header('Content-Type', $this->contentType[$extname]);
            }
            $response->sendfile($filename);
        }

        // 非调试模式，打印访问日志
        $this->printAccessLog();
    }
public function onRequest ( Request $ request , Response $ response ) { // Compat fpm server $ this -> _compatFPM ( $ request ) ; // 注入全局变量 $ GLOBALS [ '__$response' ] = $ response ; $ response -> header ( 'Server' , 'ePHP/' . $ this -> version ) ; $ filename = APP_PATH . '/public' . $ _SERVER [ 'PATH_INFO' ] ; // !in_array($extname, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico']) // Try files, otherwise route to app if ( ! is_file ( $ filename ) ) { ob_start ( ) ; ( new \ ePHP \ Core \ Application ( ) ) -> run ( ) ; $ h = ob_get_clean ( ) ; // Fixed output o byte // if (strlen($h) === 0) { //     $h = ' '; // } $ response -> end ( $ h ) ; } else { $ extname = substr ( $ filename , strrpos ( $ filename , '.' ) + 1 ) ; if ( isset ( $ this -> contentType [ $ extname ] ) ) { $ response -> header ( 'Content-Type' , $ this -> contentType [ $ extname ] ) ; } $ response -> sendfile ( $ filename ) ; } // 非调试模式，打印访问日志 $ this -> printAccessLog ( ) ; }
Linsten http server onRequest

@param  \Swoole\Http\Request  $request
@param  \Swoole\Http\Response $response
Linsten http server onRequest