Quoting https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success :
204 No Content
The server successfully processed the request and is not returning any content.
Is this part about not returning any content:
- Enforced by the HTTP protocol, so that it can be trusted that if we're getting 204 then the response surely and certainly has an empty body?
- Required by the HTTP specification and widely obeyed but not made impossible; so in practice, while a server theoretically can send a body with a code of 204, in practice it can be still assumed not to happen and if this happens then the server is broken?
- In theory required by the HTTP specification or at least strongly recommended; but in practice this cannot be relied upon as there are servers that break this assumption - in a similar way a web browser cannot assume the website it tries to fetch most certainly contains valid HTML and must be prepared to handle the opposite situation?
Or, in other words: If I'm getting an HTTP 204 response code, can I safely ignore the possibility of getting a non-empty body without fear of loss of data? Or do best practices dictate that I should check that the body is indeed empty and if it's not then I should not silently discard the returned data?