There is no standard way to do what you want.
To be precise, the standard method is to buffer the response on the server, then send 200 OK and Content-Length, and then the content. As indicated, this does not work for you.
The only alternative I can think of is to wrap the content in some format, which makes it available to detect if it was sent correctly. For example, you can complete it with a hash or even a digital signature. But, obviously, such mechanisms are not part of the HTTP standard.
source share