205 Reset Content
Clearing the document view after a successful request is the purpose of the 205 Reset Content status code. A document in this context is typically an HTML form. This response is similar to 204 in having no message body.
Usage
The 205 Reset Content status code signals the server has fulfilled the request and wants the client to reset the document view, clearing a submitted form for the next entry. The pattern suits entering a series of records one after another. A 205 response carries no message body.
Alternatively, a server sends the 204 status code. This indicates the same result, also with no message body, without specifically asking the client to reset the form.
Browsers do not reset the form
Browsers treat a 205 exactly like a 204
during navigation: the navigation aborts, the current
document stays on screen, and nothing on the page is
reset. The form keeps its submitted values. The reset
described by the status code only happens when
client-side script reads the response status and
clears the form itself, which is how single-page
applications and fetch()-driven forms use 205.
A plain HTML form posting to an endpoint that answers
205 shows no change at all. For a form that must
clear after a traditional submission, redirecting with
303 to a fresh copy of the form page is the
reliable approach.
A 205 is also absent from the list of responses
that never carry a body, which holds only
1xx, 204 and 304.
A 205 without a Content-Length
header or chunked framing on HTTP/1.1 leaves
the client reading until the connection closes, so
servers send Content-Length: 0 with the status.
Example
A script on the page posts XML data to the server. The server acknowledges the data was received and processed and asks for the entry form to be cleared. The script sees the 205 status, empties the form fields, and the page accepts the next entry, leading to new POST requests.
Request
POST /signup HTTP/1.1
Host: www.example.re
Content-Type: application/xml
Content-Length: 92
<?xml version="1.0"?>
<person>
<name>David Smith</name>
<country>USA</country>
</person>
Response
HTTP/1.1 205 Reset Content
Content-Length: 0
Code references
.NET
HttpStatusCode.ResetContent
Rust
http::StatusCode::RESET_CONTENT
Rails
:reset_content
Go
http.StatusResetContent
Symfony
Response::HTTP_RESET_CONTENT
Python3.5+
http.HTTPStatus.RESET_CONTENT
Java
java.net.HttpURLConnection.HTTP_RESET
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_RESET_CONTENT
Angular
@angular/common/http/HttpStatusCode.ResetContent
See also
- RFC 9110: HTTP Semantics
- HTML Standard: browsing the web (204 and 205 handling)
- 204
- 303
- Content-Length
- HTTP status codes