swoole_http_response::create

构造新的Http\Response对象。使用此方法前请务必调用detach方法将旧的$response对象分离,否则可能会造成对同一个请求发送两次响应内容。

function swoole_http_response::create(int $fd) : swoole_http_response;

需要2.2.0或更高版本

$http = new swoole_http_server("0.0.0.0", 9501);

$http->on('request', function ($req, Swoole\Http\Response $resp) use ($http) {
    $resp->detach();
    $resp2 = Swoole\Http\Response::create($req->fd);
    $resp2->end("hello world");
});

$http->start();