<?php
Swoole\Coroutine\Http\Client->download(string $path, string $filename, int $offset = 0)
The path of the remote file to be downloaded.
The filename of the remote file to be downloaded.
The offset of the remote file to be downloaded.
Download file at the remote URL.
<?php
use Swoole\Coroutine\HTTP\Client;
Co\run(function() {
$host = 'www.swoole.co.uk';
$cli = new Swoole\Coroutine\Http\Client($host, 443, true);
$cli->set(['timeout' => -1]);
$cli->setHeaders([
'Host' => $host,
"User-Agent" => 'Chrome/49.0.2587.3',
'Accept' => '*',
'Accept-Encoding' => 'gzip'
]);
$cli->download('/images/swoole-logo.svg', __DIR__ . '/swoole-logo.svg');
});