204 No Content
HTTP response status code 204 No Content is returned by the server to indicate that a HTTP request has been successfully completed, and there is no message body.
A 204 No Content response is cacheable by default and an ETag header is included in this case. If the default behavior needs to be overridden then the response must include the appropriate HTTP caching headers.
When the 204 No Content status code is received, it is in HTTP response to a HTTP operation such as a POST, PUT, or DELETE, where no message body is expected. In some instances, a server will instead return a 200 OK status code with no message body and a Content-Length specifier as 0.
An example of how this can be used is the result of a HTTP request generated by a user that presses a “Save" button on a form. The server commits the changes and relies on the client informing the user of success.
Depending on the operation, there are other more appropriate HTTP status codes that can be used to indicate there is no message body. For example, a conditional GET might return a 304 Not Modified status code to indicate that the resource does not have to be retrieved, and will not be present in the HTTP response.
In the example, the client posts XML data to the server that defines a job to be complete. The server responds by acknowledging that the data was accepted and the job successfully completed. There is nothing significant to return to the client in the HTTP response, so the 204 No Content status code is appropriate.
POST /job HTTP/1.1 Host: www.example.ai Content-Type: application/xml Content-Length: 67 <?xml version="1.0"> <job> <id>125</id> <task>G01</task> </job>
HTTP/1.1 204 No Content
Apache HttpComponents Core
HTTP response status code 204 No Content indicates that a HTTP request has been completed successfully, and any information being returned is in the HTTP headers. No message body will be present.