0

If an error happens while the client is still uploading the request body, what should an HTTP server do? Assume that it's not possible to discard the whole body, because the error is for example traffic exceeded or server shutdown.

  • Should it already send an HTTP error even though the upload hasn't finished?
  • Should it close the connection?
  • Both?

According to this answer, the spec-compliant way is to send an error early and the client should stop sending the body.

However, the major web browsers will continue sending the body unless you close the connection, too.

If the client is not a web browser (but rather an HTTP client library, e.g. talking to a REST API), what is the recommended behavior?

AndreKR
  • 32,613
  • 18
  • 106
  • 168
  • 2
    Possible duplicate of [Is it acceptable for a server to send a HTTP response before the entire request has been received?](https://stackoverflow.com/questions/14250991/is-it-acceptable-for-a-server-to-send-a-http-response-before-the-entire-request) – e.dan Sep 05 '17 at 07:07
  • Not a duplicate anymore after the edit. – AndreKR Sep 05 '17 at 09:11

0 Answers0