Reply sent in encrypted transmission encoding showing errors that occurred after some data has already been sent

I send a large amount of data in my response to the client in the encoding format of the transmitted channel.

How should I deal with any errors that occur halfway while writing the answer?

I would like to know if there is any HTTP specification recommended for this, so that clients know that the answer is really not successful, but that the server ran into some problems.

+6
source share
1 answer

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.

+5
source

Source: https://habr.com/ru/post/947699/


All Articles