Coroutine\Http\Client->get
最后更新于:2022-04-02 06:27:13
# Coroutine\\Http\\Client->get
[TOC]
发起`GET`请求,函数原型:
~~~
function Swoole\Coroutine\Http\Client->get(string $path);
~~~
* $path 设置URL路径,如`/index.html`,注意这里不能传入`http://domain`
* 使用get会忽略`setMethod`设置的请求方法,强制使用`GET`
## 使用实例
~~~
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 80);
$cli->setHeaders([
'Host' => "localhost",
"User-Agent" => 'Chrome/49.0.2587.3',
'Accept' => 'text/html,application/xhtml+xml,application/xml',
'Accept-Encoding' => 'gzip',
]);
$cli->get('/index.php');
echo $cli->body;
$cli->close();
~~~
';