Swoole-src: \Swoole\Client and \Swoole\Coroutine\Client returns empty response

Created on 29 Mar 2019  路  2Comments  路  Source: swoole/swoole-src

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error.
    $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);
    });
  1. 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

  2. What did you see instead?
    I got empty string
    string(0) ""

  3. 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

  1. What is your machine environment used (including version of kernel & php & gcc) ?
    ubuntu 16.04 (docker build based on php:7.2-fpm)
question

Most helpful comment


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);
});

All 2 comments

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);
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

andreybolonin picture andreybolonin  路  4Comments

erDong01 picture erDong01  路  3Comments

Gemorroj picture Gemorroj  路  3Comments

nick-zh picture nick-zh  路  3Comments

morozovsk picture morozovsk  路  3Comments