phpsocketio 接收post http请求后无法继续接收请求

Porygon

问题描述

我创建了一个Engine类继承自PHPSocketIO\Engine\Engine然后重写了其中的handleRequest方法来处理自定义的请求。 但是即使我在自定义请求部分直接$res.end("ok")后,也无法接收到后续请求.

代码如下,复现方法为:

postman中发一个post请求host/api/xxx,等返回 ok 之后在同一个标签页继续发送请求 无论是post还是get,页面会一直是sending request的状态, 启动worker的控制台中也一直没有输出, 多次get请求则不存在这个问题

class Engine extends \PHPSocketIO\Engine\Engine{
    /**
     * @param Request $req
     * @param Response $res
     */
    public function handleRequest($req,  $res)
    {
        echo('handleRequest');
        $this->prepare($req);
        $req->res = $res;
        $res->writeHead(200, '', []);
        $res->end('ok'); // 这里直接end做测试
        return;
        $this->handleApi($req, $res);
    }

    /**
     * 处理api请求
     */
    public function handleApi(Request $req, Response $res)
    {
        # code...
    }
}
297 0 0
0个回答

🔝