HTTP status code for HTTP messages

Source: Internet
Author: User
Tags 303 status code error status code html form response code

As shown earlier, the HTTP status code is divided into five categories. This section summarizes each of these five types of HTTP status codes.

100~199--Informational Status Code

The http/1.1 introduces an informational status code to the Protocol. These status codes are relatively new, and there are some controversies about their complexity and perceived value, which are limited.

status code
100 Continue"  
switching protocols Description the server is switching the protocol to the Protocol listed in the Update header, as specified by the client.

Client and Continue

If the client is sending an entity to the server and is willing to wait for the Continue response before sending the entity, the client will send a Expect request header with a value of Continue (see Appendix C). If the client does not send an entity, the Continue Expect header should not be sent because it will cause the server to mistakenly assume that the client is sending an entity.

Server with Continue

If the server receives a Expect header with a value of Continue, it responds with a Continue response or an error code. The server should never send a Continue status code to a client that does not send a Continue expectation.

If, for some reason, the server receives a partial (or all) entity before it has the opportunity to send a Continue response, the client has decided to continue sending the data so that the server does not need to send the status code. However, after the server has read the request, it should still send a final status code for the request (it can skip the Continue state).

Agent and Continue

If the agent receives a request from the client with a Continue expectation, it needs to do a few things. If the agent knows that the next hop server is http/1.1 compatible, or does not know which version the next hop server is compatible with, it should forward the Expect header down in the request. If it knows that the next hop server can only be compatible with versions prior to http/1.1, it should respond with a 417 expectation Failed error.

If the agent decides to represent a client that is compatible with http/1.0 or a previous version, put the Expect header and the Continue value in its request, then (if it receives a response from the server for a maximum of Continue) it should not forward the Continue response to the guest Because the client may not know what to do with him.

200 ~ 299--Success Status Code

These requests are usually successful when the client initiates the request. The server has a set of status codes that are used to indicate success, corresponding to different types of requests.

Status code Reason Phrases Meaning
200 Ok The request is not a problem, the entity's body part contains the requested resource.
201 Created A request to create a server object (for example, PUT). The entity body part of the response should contain the most specific references that are contained in the Url,location header that references the resource that has been created. The server must create a good object before sending this status code.
202 Accepted The request has been accepted, but the server has not performed any action on it. There is no guarantee that the server will complete the request, which simply means that it appears to be valid when the request is accepted. The server should include a description of the status of the request in the body part of the entity, and perhaps an estimate of the completion time of the request (or include a pointer to the location where this information can be obtained).
203 Non-authoritative Information

The entity header contains information that is not from the source-side server, but from a copy of the resource. This can happen if there is a copy of the resource on the intermediate node, but it cannot or does not validate the meta information (header) of the resources it sends.

This response code is not a non-use, if the entity header from the source side of the server, the response to the 200 status of the application can be used as an optional option.

204 No Content The response message contains several headers and a status line, but no body part of the entity. It is primarily used to update a browser without moving to display a new document (such as refreshing a form page).
205 Reset Content Another code that is primarily used for browsers. Responsible for informing the browser to clear all HTML form elements in the current page
206 Partial Content

A partial or Range request was successfully executed. We'll see later that the client can get some or a range of documents through some special headers-this status code indicates that the scope request was successful.

The 206 response must contain the Content-range, Date, and ETag or content-location header.

300 ~ 399--REDIRECT Status code

The redirect status code either tells the client to use an alternate location to access the resource that they are interested in, or it provides an alternative response instead of the content of the resource. If the resource has been moved, you can send a redirect status code and an optional location header to tell the client that the resource has been moved and where it can now be found.

650) this.width=650; "src=" Https:// "title=" 1.png "alt=" Wkiol1jblogrx_wvaacotpvfvee819.png "/>

Some redirection status codes can be used to validate the application local copy of the resource against the resource on the source-side server. For example, an HTTP application can see if the local copy of its resource is still up-to-date, or if the resource has been modified on the source-side server.

The client sends a special If-modified-since header that reads only the documents that were modified since October 1997. After this date, the document has not been modified, so the server sends back a 304 status code instead of the contents of the document.

650) this.width=650; "src=" Https:// "title=" 2.png "alt=" Wkiom1jblo7iwdajaacifprgm6g812.png "/>

In summary, when responding to a non-HEAD request that contains a redirect status code, it is a good idea to include an entity that contains descriptive information and a connection to the (multiple) redirect URL in the entity.

Status code Reason Phrases Meaning
300 Multiple Choices This status code is returned when the client requests a URL that actually points to multiple resources, such as the English and French versions of an HTML document on the server. This code is returned with a list of options, so that the user can select the one that he wants to use, and when multiple versions are available, the client needs to communicate, and more about this information, see Chapter 17th. The server can include the preferred URL at the location header
301 Moved Permanently Used when the requested URL has been removed. The location header of the response should contain the URL where the resource is now located
302 Found Similar to the 301 status code, however, the client should use the URL given by the location header to temporarily locate the resource. Future requests should still use the old URL
60V See other Informs the client that another URL should be used to obtain the resource. The new URL is located at the location header of the response message. Its primary purpose is to allow the response of a POST request to direct the client to a resource.
304 Not Modified The client can make its request conditional by the included request header. For more information on the condition header, see Chapter Iii. If the client initiates a conditional GET request and the recent resource is not modified, the status code can be used to indicate that the resource has not been modified. A response with this status code should not contain the body part of the entity.
305 Use Proxy Used to indicate that a resource must be accessed through a proxy, and the location of the agent is given by the position header. It is important that the client resolves this response relative to a particular resource and cannot assume that all requests, even all requests to the server holding the requested resource, are made through this proxy. If the client mistakenly causes the agent to intervene in a request, it can cause destructive behavior and create a security vulnerability.
60S (Not used) Not currently used
307 Temporary Redirect Similar to the 301 status code, but the client should use the URL given by the location header to temporarily locate the resource. Future requests should use the old URL

When the http/1.0 client initiates a POST request and receives a 302 redirect status code in the response, it accepts the redirect URL of the location header and initiates a GET request to that URL (rather than initiating a POST request as in the original request).

The problem is http/1.1. The http/1.1 specification uses a 303 status code to implement the same behavior (the server sends a 303 status code to redirect the client's POST request, followed by a GET request).

To avoid this problem, the http/1.1 specification states that for http/1.1 clients, the 307 status code replaces the 302 status code for temporary redirection. This allows the server to keep the 302 status code for use by the http/1.0 client.

In this way, the server chooses the appropriate redirect state to send in the redirect response, and it needs to look at the HTTP version of the customer's degree.

400 ~ 499--Client Error Status code

Sometimes the client sends something that the server cannot handle, such as a malformed request message, or, most commonly, a non-existent URL.

Status code Reason Phrases Meaning
400 Bad Request Used to tell the client that it sent over a wrong request
401 Unauthorized Return with the appropriate header, where the client is requested to authenticate itself before obtaining access to the resource.
402 Payment Required The status code is not yet in use, but it has been reserved for future use.
403 Forbidden Used to indicate that the request was rejected by the server. If the server wants to explain why a request is rejected, you can include the body part of the entity to describe the reason. However, this status code is usually used when the server does not want to indicate the reason for the rejection.
404 Not Found Used to indicate that the server could not find the requested URL. Typically contains an entity so that the client application is displayed to the user.
405 Method not allowed This status code is used when initiating a request with a method that is not supported by the requested URL. The Allow header should be included in the response to tell the client which methods are available to the requested resource.
50W Not acceptable Clients can specify parameters to describe what type of entity they are willing to receive. This code is used when the server does not have a resource that matches the client's acceptable URL. Typically, the server contains some headers that tell the client to figure out what requests are not met.
50V Proxy Authentication Required Similar to the 401 status code, but used for proxy servers that require authentication of resources.
408 Request Timeout If the client takes too long to complete the request, the server can echo the status code and close the connection. Hyper-time gizzard servers vary, but are usually long enough for all legitimate requests.
409 Conflict Used to describe some of the conflicts that a request might cause on a resource. This status code can be sent when the server is concerned that the request will cause a conflict. The response should contain a principal that describes the conflict.
410 Gone Similar to 404, only the server has ever had this resource. It is primarily used for WEB site maintenance, so that the Server Manager can notify the client when the resource is removed.
411 Length Required The server requires that the Content-length header be included in the request message. For more information on the Content-length header, see section 3.5.4.
412 Precondition Failed The client initiates a conditional request and uses it when one of the conditions fails. A conditional request is initiated when the client contains the Expect header. For more information on the Expect header, see Appendix C, Expect section
413 Request Entity Too Large This status code is used when a client sends an entity body part that is larger than the server can or wants to handle
414 Request URI Too Long This status code is used when the request URL in the client's request is longer than the server can or wants to process
415 Unsupported Media Type This status code is used when the server does not understand or cannot support content types for entities that are sent by the client
416 Requested Range not satisfiable This status code is used when the request message requests a range of the specified resource, which is invalid or cannot be satisfied.
417 Expectation Failed

The requested Expect request header contains an expectation, but this status code is used when the server is unable to meet this expectation.

This response status code can be sent if the agent or other intermediary application has the exact evidence that the source server will generate a failed expectation for a request.

500 ~ 599--Server Error Status code

Sometimes the client sends a valid request, and the server itself has an error. This may be the client encountered a server defect, or a child element on the server, such as a gateway resource, went wrong.

Status code Reason Phrases Meaning
500 Internal Server Error This status code is used when the server encounters an error that prevents it from serving the request.
501 Not implemented This status code is used when a client-initiated request exceeds the capabilities of the server (for example, using a request method that is not supported by the server)
502 Bad Gateway Use this status code when a server that is used as a proxy or gateway receives a pseudo-response from the next hop on the request response chain (for example, it cannot connect to its parent gateway)
40R Serivce unavailable Used to indicate that the server is now unable to service the request, but will be available in the future. If the server knows what hand resources will become available, a Retry-after header can be included in the response. For more information on the Retry-after header, see section 3.5.3.
504 Gateway Timeout Similar to status code 408, except that the response here is from a gateway or proxy that timed out waiting for the other server to respond to its request
505 HTTP Version not supported This status code is used when the server receives a request that uses a protocol version that it cannot or is unwilling to support. Some server applications choose an earlier version that does not support the protocol

This article from "Professor elder brother" blog, reprint please contact the author!

HTTP status code for HTTP messages

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.