Please answer these questions before submitting your issue. Thanks!
$cli = new swoole_http_client('reqres.in', 80);
$cli->setHeaders([
'Host' => 'reqres.in',
"User-Agent" => 'Chrome/49.0.2587.3',
'Accept' => 'text/html,application/xhtml+xml,application/xml,application/json',
'Accept-Encoding' => 'gzip',
]);
$cli->get('/api/users?page=2l', function ($cli) {
var_dump($cli->body);
});
What did you expect to see?
I expected to receive json string from https://reqres.in/
the same as I can get with guzzlehttp client
What did you see instead?
I got empty string
string(0) ""
What version of Swoole are you using (show your php --ri swoole)?
www-data@fb228f132589:~$ php --ri swoole
swoole
swoole support => enabled
Version => 4.2.9
Author => Swoole Group[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2r 26 Feb 2019
http2 => 1.18.1
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => 1 => 1
swoole.unixsock_buffer_size => 8388608 => 8388608
I got fail too.
go(function () {
$cli = new Co\Http\Client('reqres.in', 443, true);
$cli->set([
'timeout' => -1,
'ssl_host_name' => 'reqres.in'
]);
$cli->get('/');
var_dump($cli);
});
Most helpful comment