Hello friends, in previous articles we have discussed about Http status code 1xx. In this article we are going to discuss about status http response codes 2xx and meaning.
So let’s start.
The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:
If you sent GET request then relevant data will be returned in response.
If you sent POST request then data containing the result of the action will be returned in response.
In each succeeded response, 200 status code will be returned to inform client that request is successfully completed.
Following a POST command, this indicates success, but the textual part of the response line indicates the URI by which the newly created document should be known.
Client sent a new request to server:
POST /edit/ HTTP/1.1 Host: example.org User-Agent: Thingio/1.0 Authorization: Basic ZGFmZnk6c2VjZXJldA== Content-Type: application/atom+xml;type=entry Content-Length: nnn Slug: First Post <?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom"> <title>Atom-Powered Robots Run Amok</title> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <author><name>John Doe</name></author> <content>Some text.</content> </entry>
The server signals a successful creation with a status code of 201. The response includes a Location header indicating the Member Entry URI of the Atom Entry, and a representation of that Entry in the body of the response.
HTTP/1.1 201 Created Date: Fri, 7 Oct 2005 17:17:11 GMT Content-Length: nnn Content-Type: application/atom+xml;type=entry;charset="utf-8" Location: http://example.org/edit/first-post.atom ETag: "c180de84f991g8"
The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.
A 201 response MAY contain an ETag response header field indicating the current value of the entity tag for the requested entity just created.
The status code 202 indicates that server has received and understood the request, and that it has been accepted for processing, although it may not be processed immediately.
The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process without requiring that the user agent’s connection to the server persist until the process is completed. The entity returned with this response should include an indication of the request’s current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.
203-Non-Authoritative Information (since HTTP/1.1)
When received in the response to a GET command, this indicates that the returned meta information is not a definitive set of the object from a server. It is from a private overlaid web. This may include annotation information about the object. The set presented MAY be a subset or superset of the original version. We say it partial because this is not from origin server. This is from third party web.
This is virtually identical in meaning to a 200 status code.
There are several requests for which we do not expect any response message body. In those cases the 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
This is just a notification for client that server has received the request but there is no information to send back, and the client should stay in the same document view.
The server has fulfilled the request and the user agent should reset the document view which caused the request to be sent. A value of 205 (SC_RESET_CONTENT) means that there is no new document, but the browser should reset the document view. This status code instructs browsers to clear form fields.
Once browser has clear all form fields, user can initiate another input action.
We’ve discussed about range requests in bandwidth optimization as part of Http 1.1.
By using this way a client can send a request and in the request it can mention a range to get. Once server processes this requests and if server supports range requests then server will transfer the range of bytes requested by client.
Following is the example of one range request.
In above example we can see that range from 0 to 1023 bytes is requested from server.
If a response contains a range, rather than the entire resource, it carries the 206 (Partial Content) status code.
The 207 (Multi-Status) status code provides status for multiple independent operations. The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.
E.g. if you perform an operation like POST, PUT, DELETE against more than one resource and the operations against each individual resource did not share a common outcome then this is ideal scenario to use status code 207.
The 208 (Already Reported) status code can be used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings of the same collection repeatedly. For each binding of a collection inside the request’s scope, only one will be reported with a 200 status, while subsequent DAV: response elements for all other bindings will use the 208 status, and no DAV: response elements for their descendants are included.
This is for server performance improvement as well as bandwidth optimization.
A 226 IM Used response means that the server has fulfilled a request for the resource; however, the response is a demonstration of the result of at least one or more instance-manipulations assigned to the current instance.
The actual current instance might not be available except by combining this response with other previous or future responses, as appropriate for the specific instance-manipulation(s).
HTTP/1.1 226 IM Used Date: Sat, 06 Apr 2013 21:10:40 GMT Server: Apache/2.4.4 (Unix) Content-Length: 500 Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>226 IM Used</title> </head><body> <h1 id="IM_Used">IM Used <a class="sl" href="#IM_Used"></a></h1> </body></html>
That’s it about Http 2xx status codes. In upcoming articles we’ll discuss about next set of codes.