Swoole\Coroutine\FastCGI\Client->execute(...)

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Coroutine\FastCGI\Client->execute(Swoole\FastCGI\HttpRequest $request, float $timeout = -1): Swoole\FastCGI\HttpResponse

Parameters

request

The built up FastCGI Client request object. This object is used to setup the request to send. It must be a Swoole\\FastCGI\\HttpRequest object.

timeout

The default is to never time out (-1) but you may set a timeout in seconds. So 1.5 means 1.5 seconds.

Return

Returns a Swoole\\FastCGI\\HttpResponse object. You can catch any errors by using a try-catch with this client.


Description

Execute the request to the FPM server and return the response.

The returned Swoole\FastCGI\HttpResponse object contains the information from the FPM response.

The most commonly used request object is Swoole\FastCGI\HttpRequest but you may also use Swoole\FastCGI\Request which is used for when you are not sending a HTTP request. Refer to the documentation on the request and response objects for more details.

Any errors will thrown an Swoole\Coroutine\FastCGI\Client\Exception, checkout the Dealing with errors section.


Example

Checkout the main examples to see how this method is used and how to process a response.

Last updated on August 31, 2022