<?php
namespace app\controller;
use support\Request;
use support\Response;
use Workerman\Protocols\Http\Chunk;
class IndexController
{
public function index(Request $request)
{
$connection = $request->connection;
$http = new \Workerman\Http\Client();
$http->get('https://example.com/', function ($response) use ($connection) {
$connection->send(new Chunk($response->getBody()));
$connection->send(new Chunk('')); // 发送空的的chunk作为结束标志
});
return response()->withHeaders([
"Transfer-Encoding" => "chunked",
]);
}
}
webman里用的话,先发送一个chunked头,然后再异步发送给chunk数据,类似这样
好的,明白了,谢谢老大