HTTP for HTML Authors, Part III - HTML with Style Message created Message accepted
Most of the time, the standard 200 OK code is appropriate. Usually it means that whatever request the form submission made was fulfilled and the resulting document is the result or confirmation of this action.
There are a couple of other responses you might want to use however. If the submission causes some resource to be created, you might want to use the 201 Created status code together with the Location header to redirect the user to the resource. This will usually be in response to a POST query. For instance, let's assume that a user of a Web-based forum posts a message to a discussion board through a form. The response could be something like this:
If you're less fussy about space than I am in this last example you'll probably be more creative with the document you send along confirming the message creation, but you get the idea. The user agent should redirect the user to the location of the created resource immediately. Some older browser's don't support this, while others might opt to wait for the user to confirm the redirection, which is why we also supply a document confirming the creation.
Another useful code is 202 Accepted. This status code implies that the form data has been accepted for processing, but nothing has happened because of it. The body of the response should contain a document which explains that the data has been received and will soon be acted on upon, perhaps linking to a URL that will tell the user how his request is progressing.
HTTP/1.1 202 Accepted Content-Type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html40/strict.dtd"> <title>Message accepted</title>
Your message has been accepted and will be posted shortly.
Produced by Stephanos Piperoglou
Created: March 15, 2001
Revised: March 16, 2001