run(function () {
$host = 'tp.com';
$uri = '/index/ta';
$client = new Client($host);
$client->set([
'timeout' => -1,
]);
$client->connect();
$req = new Request();
$req->method = 'POST';
$req->path = $uri;
$req->headers = [
'host' => $host,
'user-agent' => 'Chrome/49.0.2587.3',
'accept' => 'text/html,application/xhtml+xml,application/xml,application/json',
// 'accept' => '*/*',
'accept-encoding' => 'gzip',
'content-type' => 'application/json',
];
// $arrData = $this->setData();
$req->data = '{"user":"aa"}';
$client->send($req);
$res = $client->recv();
var_dump($res->data);
});
这是上面代码的本地执行结果
WARNING Socket::recv_packet_with_length_protocol() (ERRNO 1201): packet length is too big, remote_addr=192.168.33.1:80, length=4740189
这是通过postman请求接口获取的结果
这是swoole版本
刚刚查阅了一些资料,发现:使用http2的前提是服务端必须开启了http2,我的本地nginx服务根本没有配置。使用http2必须和https一起使用,我的服务端是http。请问诸位大佬,是这个原因么