RoadRunner supports HTTP response streaming. This feature means that responses can be sent to the client in chunks. It is useful when you need to send a large amount of data to the client. You don't need to update the configuration to enable this feature. It is enabled by default and controlled by the PHP worker.
Samples
Sending a response in chunks
The size of the chunks is controlled by the PHP worker. You can send a chunk by calling the respond() method of the Spiral\RoadRunner\Http\HttpWorker class. The signature of the method is the following:
The $body parameter can be a string or a generator. If it is a generator, the worker will iterate over it and send chunks to the client. $status and $headers are the same as in the respond() method of the Spiral\RoadRunner\Http\HttpWorker class. The $endOfStream parameter indicates whether the response is finished. If set to false, the worker will wait for the next chunk.
In this example, we send 5 status codes and 5 headers to the client. You may send a 103 Early Hints status code (or any 1XX status code) to the client at any time during streaming (do not forget about $endOfStream).