class Emitter implements EmitterInterface
Sends a response, streaming it only where streaming is what was asked for.
Nearly everything Flarum returns is a complete string that should be sent in one go, which is what {\Laminas\HttpHandlerRunner\Emitter\SapiEmitter} does. A handful of things — clearing the cache, which recompiles every asset and can run for half a minute — need to reach the browser as they happen, and for those the body is a {\Laminas\Diactoros\CallbackStream} whose callback writes and flushes progressively. The distinction is drawn on the body rather than a flag, because `SapiEmitter` would defeat a callback body anyway: it casts the stream to a string, which runs the callback to completion before a single byte is sent. Before streaming, PHP is told not to hold the body back itself: the output buffers `output_buffering` opens are closed, so the callback's `flush()` reaches the server, and `zlib.output_compression` is turned off, as it would gather the body to compress it. {\Flarum\Http\EventStream} builds such a response.
Methods
No description
Stops PHP holding a streamed body back. A buffer that already holds output is left alone, for the emitter to report as output sent too soon.
Details
at
line 43
__construct( EmitterInterface $buffered = new SapiEmitter(), EmitterInterface $streamed = new SapiStreamEmitter(), Closure|null $prepareToStream = null)
at
line 50
bool
emit( ResponseInterface $response)
at
line 65
static void
prepareToStream()
Stops PHP holding a streamed body back. A buffer that already holds output is left alone, for the emitter to report as output sent too soon.