发起GET
请求,函数原型:
function swoole_http_client->get(string $path, callable $callback);
/index.html
,注意这里不能传入http://domain
GET
方法,可使用setMethod
设置新的请求方法$cli = new swoole_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', function ($cli) {
echo "Length: " . strlen($cli->body) . "\n";
echo $cli->body;
});