Open sshymko opened 6 years ago
+1 for those handlers
wait, if you have not used the write
method, all data(included header) will be sent after you call end
.
twose is ok - for me i did not found any real usecase last weeks
@flddr and @twose Transparent profiling of an application regardless of the response population workflow is the use case. Library upscalesoftware/swoole-blackfire introduces the response proxy with the event subscription. There is no way to stop the profiling and append the response headers with the profiling results before the body is sent by an application being profiled without modifying the application itself.
There's a number of use cases that require tracking response lifecycle: before/after sending headers, before/after sending response body to a client. It would be great to be able to subscribe custom handlers for all such events.
For example:
Another good use case is profiling, for example, via Blackfire. The profiler needs to start at the very beginning of the request handling (already supported) and stop right before sending out response headers to be able to report results in custom headers. See upscalesoftware/swoole-blackfire.
For example:
The profiler above would work regardless of how the business logic prepares the response. Otherwise, the profiler stop call needs to be carefully placed right before the business logic sends the response. It's unnecessary burden for a developer to strategically place the stop call in different places for each application intended to be profiled. Moreover, a poorly-designed application may not even have a single place of the response preparation. Such apps still need to be profiled somehow :)