Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
pecl install openswoole-22.0.0
<?php Swoole\Coroutine\Http2\Client->recv(float $timeout): Swoole\Http2\Response
In seconds, the timeout of the request, 1.5 means 1.5 seconds. See the timeout guide link below.
Returns a client
Swoole\Http2\Response object when successful and
false when not, check
$client->errCode for more details upon an error.
Receive a response from the remote host.
When using this method, while waiting for IO Swoole will switch coroutines so resources are not wasted and return upon a response or failure.
The built in HTTP clients have a timeout option, allowing you to wait for a response, the timeout can be set in a few different ways, refer to the timeout guide for more information. However, the
$timeout parameter will work in most cases.
Response HTTP/2 Object
This method returns a
Swoole\Http2\Response object which is a class with no methods, only public class properties which you can access, see the response object documentation for more details and what it contains. This object is only returned on a successful response. Check
$client->errCode if you receive
Check the main Quick Start Examples to see how the
recv() method is used in its full context.