An explanation of the HTTP protocol status code

Source: Internet
Author: User
Tags error status code

Transferred from: http://www.cnblogs.com/TankXiao/
What is an HTTP status code

The HTTP status code is used by the Web server to tell the client what has happened.

The status code, located in the first line of HTTP Response, returns a "three-digit status code" and a "status message." The "three-digit status code" is easy for the program to process, and "status messages" are easier to understand.

Status Code classification

HTTP status code is divided into five categories, currently we use the HTTP protocol version is 1.1, support the following status code. As the protocol progresses, more status codes are defined in the HTTP specification.

Defined range Classification
1XX 100-101 Information Tips
2XX 200-206 Success
3XX 300-305 redirect
4XX 400-415 Client Error
5XX 500-505 Server error
Common Status Codes

The average person just needs to know the following common status code is enough.

The $ OK Server successfully processed the request (this is the most we have seen)
301/302 Moved Permanently (redirected) the URL of the request has been moved. A location URL should be included in the response to indicate where the resource is now located
304 not Modified (unmodified) the client's cache resource is up-to-date for clients to use the cache
404 Not Found resource not found
501 Internal Server error server encountered an error that prevented it from serving the request
1XX Informational Status Code

These status codes are introduced in HTTP 1.1. There's a debate about the value of these status codes.

Status code Status messages Meaning
100 Continue (continued) The starting part of the request is received and the client should continue to request
101 Switching protocols (switching protocol) The server is switching the protocol to the Protocol listed in the update header based on the client's instructions
2XX Success Status Code

When a

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

Status code Status messages Meaning
200 Ok The server successfully processed the request (this is the most we have seen)
201 Created (created) The resource has been created for requests that require the server to create objects.
202 Accepted (accepted) The request has been accepted, but the server has not yet processed
203 Non-authoritative Information (non-authoritative information) The server has successfully processed the transaction, except that the entity header contains information that is not from the original server but from a copy of the resource.
204 No content (no contents) Response contains headers and a status line, but does not include the subject content of the entity (no response body)
205 Reset content (Reset contents) Another code that is primarily used for browsers. This means that the browser should reset all the HTML forms on the current page.
206 Partial content (partial) Partial request succeeded
3XX REDIRECT Status code

Redirect status codes are used to tell browser clients that the resources they access have been moved, that the Web server sends a redirect status code and an optional location Header, which tells the client where the new resource address is.

The browser client will automatically resend the new request with the address provided in location. This process is transparent to the user.

301 and 302 are very similar, one is permanent transfer, one is temporary transfer. (In our opinion, these two are not much different)

302,303,307 is the same. This is because 302 is defined by HTTP 1.0 and is used in HTTP1.1 303,307.  At the same time retained 302. (But in reality, we still use 302, I haven't seen 303 and 307)

So this section, we just need to master 302, 304 on it.

Status code Status messages Meaning
300 Multiple Choices (multiple selection) The client requests a URL that actually points to multiple resources. This code is returned with a list of options, and then the user can choose the option he wants.
301 Moved permanently (permanently removed) The requested URL has been moved. A location URL should be included in the response to indicate where the resource is now located
60W Found (found) Similar to Status Code 301. But the removal here is temporary. The client will resend the new HTTP request using the URL given in the location
303 See other Similar to 302
304 Not Modified (unmodified) The client's cache resource is up-to-date for clients to use the cache
305 Use proxy (using proxies) The resource must be accessed through a proxy, the address of the agent is in the location of response
306 Not used This status code is not currently used
307 Temporary Redirect (Temporary redirect Similar to 302
4XX Client Error status code

Sometimes the client sends something that the server cannot handle, such as a malformed request, or, most commonly, a URL that does not exist.

Status code Status messages Meaning
400 Bad Request Tells the client that it sent an incorrect request.
401 Unauthorized (not authorized) Requires the client to authenticate itself
402 Payment Required (Requires payment) This state has not been used and is reserved for future use
403 Forbidden (Forbidden) The request was rejected by the server
50U Not Found (not found) Resource not Found
405 Method not allowed (methods not allowed) The method of the request is not supported.
50W Not acceptable (unacceptable)
407 Proxy authentication Required (requires agent authentication) Similar to status code 401 for proxy servers that require authentication
408 Request Timeout (requests timed out) If the client takes too long to complete the request, the server can echo the status code and close the connection
409 Conflict (conflict) The request caused some conflict on the resource
410 Gone (disappeared) The server used to have this resource, and now it's gone, similar to status code 404
411 Length Required (requires long indication) The server requires that Content-length be included in the request.
412 Precondition Failed (Prerequisite failure)
413 Request entity Too Large (requesting entities too large) The entity body part sent by the client is larger than the server can or wants to handle
414 Request URI Too Long (requests URI is too lengthy) The client sends a request with a URL that exceeds the length that the server can or wants to process
415 Unsupported media type (not supported) The server does not understand or does not support the content type of the entity sent by the client
416 Requested range not satisfiable (the requested range is not met)
417 Expectation Failed (unable to meet expectations)
5XX Server Error Status code

Sometimes the client sends a valid request, and the Web server itself has an error. Either the Web server is running in error or the Web site is dead.   5XX is used to describe server errors.

Status code Status messages Meaning
500 Internal Server error (internal server errors) The server encountered an error that prevented it from serving the request
501 Not implemented (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 (gateways fail) The server used by the agent encountered an invalid upstream response
503 Service Unavailable (not available) The server is currently unable to service the request, but can recover the service over time
504 Gateway Timeout (gateways timed out) Similar to the status 408, but the response comes from the gateway or proxy, and this gateway or proxy has timed out while waiting for the response from another server
505 HTTP version not supported (HTTP versions not supported) The server received a request that uses an HTTP protocol version that it does not support. Some servers do not support HTTP earlier HTTP protocol versions, nor do they support too high protocol versions

An explanation of the HTTP protocol status code

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: info-contact@alibabacloud.com 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.