The Swoole\FastCGI\HttpResponse is an object which is returned when calling Swoole\\Coroutine\\FastCGI\\Client->execute, after executing a request you are returned a response object. You can then interact with this response object to get information and data from a FastCGI Client response.


You may have already seen a few examples using this response object, if not it may be good to look at the advanced example to see how the response object is used in proper context.


$client = new Swoole\Coroutine\FastCGI\Client('', 9000);

// Make your request object here and set other options...

// After a successful request we get the response object
$response = $client->execute($request);


Once you have built your response object you can interact with it to see what the response holds, there are many methods which you have access to:



// Get the response status code
echo "Status Code: $response->getStatusCode()\n";

// Get the Reason Phrase from the response
echo "Reason Phrase: $response->getReasonPhrase()\n";

// Get a specific header from the response...
echo "X-Foo Header Value: $response->getHeader('X-Foo')\n";

// Get all the headers as an array from the response
echo "All Headers:" . var_dump($response->getHeaders()) . "\n";

// Get the cookies from the response as an array
echo "Cookies:" . var_dump($response->getSetCookieHeaderLines()) . "\n";

// Output the whole body response content
echo "Body Result: \n{$response->getBody()}";

For a full example checkout the advanced example which shows proper context and use.

For more details on this response object checkout its source code.