Response object

Life cycle

The Response implements the singleton pattern in the EasySwoole. It's created automatically since a HTTP client's request is received and destroyed automatically till the end of the process. The Request object fully conforms to all the specifications in [PSR7].

Other details, interested students can view the corresponding code in the IDE.

Methods List


This method is used to respond data to the client.

$this->response()->write('hello world');


This method is used to redirect the request to another specified URL



Set a Cookie to the client in the same way as the original setCookie.


Used to get the original swoole_http_response instance.


Explicitly stop the response. After this, you can not respond any more data to the client.


When you don't know whether the response has been ended, you may use this method to determine whether you can still respond data to the client:

    $this->response()->write('Continue sending data');

PSR-7 Specification Response Object Commonly Used Methods


Send HTTP status code to client.


Note: $statusCode must be a standard HTTP allowable status code, see the Status object in Http Message for details.


Used to send a header to an HTTP client.


0 results matching ""

    No results matching ""