Once you start sending HTTP headers to the client, you cannot send anything else. You must finish sending the answer that you intend to send, i.e. Recorded data and related headers. If the error occurs halfway through this, it is not possible to report this error to the client. All you can do is close the connection. Either the client does not receive all the headers, or it does not receive the ending fragment of length 0 at the end of the response. In any case, it is enough for the client to know that the server has detected an error while sending.
source share