Swoole Coroutine HTTP/2 Client Response Object


Description

When sending a request using the HTTP/2 Client it will return a Swoole\Http2\Response object after a successful request, you then use this object to access information about the response that was returned from the remote host.

The Swoole\Http2\Response object does not have any methods, only public class properties which you can use to get data from.

This object is returned from recv() and read().


The response object is built up of the following:

<?php

...

$response = $client->recv(...);

var_dump($response->statusCode);
var_dump($response->headers);
var_dump($response->cookies);
var_dump($response->set_cookie_headers);
var_dump($response->data);

...


Class Properties

  • statusCode: HTTP status code sent by the server, such as 200, 502, etc.

  • headers: Header information sent by the server.

  • cookies: Cookie information set by the server.

  • set_cookie_headers: The original cookie information returned by the server, including the domain and path items.

  • data: The response body sent by the server.


Example

Check the main Quick Start Examples to see how the response object is used in its full context.