ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 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); }); ~~~