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

Latest version: pecl install openswoole-22.1.2


<?php Swoole\Http\Response->end(string $data): bool



The data to send back to the client, the HTTP body



If successful, true is returned otherwise false


Sends back data to the client, data is send to the HTTP body and then the request is terminated after the response has finished sending. You can only ever call this method once.

If the client enables keepalive, the connection between the server and the client will maintained but if the client doesn't enable keepalive, the connection between the server and the client will be closed.


Swoole\Http\Response->end(string $data);

$server->on('Request', function(Swoole/Server/Request $request, Swoole/Server/Response $response)
  // Send
  $response->end('<h1>Hello World!</h1> <br/> <p>from Swoole.</p>');


  • If you need to send dta to the client multiple times or chunk data, use the server $response->write method instead

  • By default both the ->end() and ->write() methods only support sending data up to 2M, this can be increased by adjusting the buffer_output_size

  • If you exceed the set buffer_output_size, you will receive the following error:

WARNING finish (ERRNO 1203): The length of data [262144] exceeds the output buffer size[131072], please use the sendfile, chunked transfer mode or adjust the output_buffer_size
Last updated on August 31, 2022