企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Coroutine\\Http2\\Client [TOC] `Http2`协程客户端。 ## 实例 ~~~ go(function () { $domain = 'www.zhihu.com'; $cli = new Swoole\Coroutine\Http2\Client($domain, 443, true); $cli->set([ 'timeout' => -1, 'ssl_host_name' => $domain ]); $cli->connect(); $req = new swoole_http2_request; $req->method = 'POST'; $req->path = '/api/v4/answers/300000000/voters'; $req->headers = [ 'host' => $domain, "user-agent" => 'Chrome/49.0.2587.3', 'accept' => 'text/html,application/xhtml+xml,application/xml', 'accept-encoding' => 'gzip' ]; $req->data = '{"type":"up"}'; $cli->send($req); $response = $cli->recv(); assert(json_decode($response->data)->error->code === 602); }); ~~~