The HTTP status code

When we are little point with the mouse, or keyboard spluttered pa, a fierce like a tiger, operation during a visit to a particular page in the browser, we actually is through the browser launched a request to provide the specified services server, the server can’t just go silent (although silence is gold), for we through the browser making the request, The server always has to respond. This is the HTTP status code. Today we will take a look at the commonly used HTTP status code.

Classification of HTTP status codes

There are many responses from the server to the client, so there are also many response status codes. Different status codes represent different feedback information. However, in general, HTTP status codes can be divided into the following five categories:

classification describe
1 * * Informational status code: indicates that the server receives a request and needs to continue operations
2 * * Yes, the operation was received and processed successfully
3 * * Redirect, further action is required to complete the request
4 * * Client error
5 * * Server internal error

1 * * status code

In a word, the revolution has not yet succeeded, and comrades still need to work hard.

The status code of 1xx refers to the status code temporarily corresponding to the server and requiring the client to continue to perform subsequent operations. The most common ones are 100,101,102.

  • 100 (Continue) : The client needs to Continue to complete subsequent requests. This also indicates that the client has sent part of the request and the server has not rejected it. That is, the server receives some requests from the client and does not reject them and expects the client to continue to complete subsequent requests.
  • 101 (Switching Protocols) : A client requests a server switch protocol, the server receives the request and is ready to switch.
  • 102 (Processing) : Status code extended by WebDAV (RFC 2518) indicating that Processing will continue.

Error screen

Usually, a 1** status code indicates that there is no problem and subsequent operations need to be continued, so there is no need to troubleshoot any errors.

2 * * status code

The 2** status code indicates that the request was successfully received and processed, but that the receive was received. How, whether, and how much was processed depends on the server. The server is sending you back this thing that says I’m handling it so I’m handling it.

A word summary: server: I say processing success is processing success!

The most common 2** status code is 200, followed by 201,202,203,204,205,206,207. Among them, 200,204,206 are often tested

  • 200 (OK) : The request is successful, and the requested resource is returned with the response header and data body.
  • 201 (Created) : This request requires the creation of a resource on the server. This response indicates that the requested resource has been Created successfully.
  • 202 (Accepted) : A server receives a request from a client, but the server is arrogant, indicating that the request is not being processed immediately and may or may not be processed eventually. This kind of comparison is suitable for asynchronous operations, which do not require the client to wait for the operation to complete and directly return information to the client. You can also see from this that a request server of 2** is not necessarily successful.
  • 203 (non-authoriative Information) : The server promises that it has received and processed the request, but says that this Information is not absolutely reliable. He states that the entity header meta-information returned is not a valid set on the original server, but a local or third party copy. The current information may be a subset or superset of the original version.
  • 204 (No Content) : Indicates that the server received the request from the client and processed it successfully without returning any physical Content.
  • 205 (Reset Content) : As the English name indicates, this status code indicates that the server successfully received and processed the client request, but requires the requester to Reset the document view (mainly used for the Reset form after user input).
  • 206 (Partial Content) : The server successfully processed a Partial GET request.
  • 207 (multi-status) : The following message is an XML message and may contain a series of independent response codes.

Error screen

For the status code of 2**, the server’s attitude is positive, the server says it successfully processed, so this response status code is what we want to see, there is no need to check. If you need to check, check to see if that’s the case.

3 * * status code

3** status code indicates the redirection status code, which is a shirking practice of the server. It means to find someone else instead of me. Redirection includes temporary and permanent redirection. A temporary redirect should still be requested by the next client.

In a word: I don’t care, this time to find someone else, or in the future to find someone else!

3 * * common 300301302303304305307 status code.

  • 300 (Multiple Choices) : Multiple Choices. The requested resource (emphasis resources) has a selection of feedback information. Users or browsers can select an address for redirection.
  • 301 (Moved Permanently, Permanently) : The requested resource Moved Permanently to a new location, and any future requests to that resource should use the new URI.
  • 302 (Found) : A temporary redirection Found that another URI can respond to a request for the resource, but this is only temporary. The client’s next request for the resource remains the same.
  • 303 (See Other) : Also a temporary redirect, the response to the request can be found at another URI. Unlike 302, this status code requires that the client access the resource in GET mode.
  • 304 (Not Modified) : Indicates that the requested resource has Not changed since the last access, based on the request condition. The status code requires that the client send a conditional GET request.
  • 305 (Use Proxy) : The requested resource can be accessed only through the specified Proxy.
  • Temporary Redirect (307) : indicates a Temporary Redirect. Since the Redirect is Temporary, the client should continue to send future requests to the original address.

Error screen

The 3** series of status codes indicate that the request is not impossible to process, but only needs to be redirected. Whether the request is temporarily redirected or permanently redirected depends on the subdivision of the status code, so this status code itself is not a big problem.

4 * * status code

The 4** status code indicates that the client has an error. Either the request contains a syntax error or the request parameters are not recognized by the server and the request cannot be processed. Then the server can dump the blame. It’s none of my business.

A word summary: server: you are wrong, wrong have to admit, have to change, strive for a good client!

Common 4** status codes are 400,401,403,404,404,408.

  • 400 (Bad Request) : If there is a syntax or semantic error in the Request, or the Request parameters are incorrect, the client should not Request any more if they are not corrected.
  • 401 (Unauthorized) : This request requires user authentication, which is not enabled for this request.
  • 403 (Forbidden) : The server has understood the request but refuses to execute it.
  • 404 (File Not Found) : 404 (File Not Found) : 404 (File Not Found)
  • 408 (Request time-out) : The Request times out. The client did not finish sending a request within the time the server was waiting.

Error screen

When this problem occurs, we generally need to check whether the request is correct, such as whether the URL of the request is written correctly, whether the parameters of the request are correct, and whether the request for authentication is authenticated correctly. In addition, we need to check the server to see if the specified resource exists.

5 * * status code

5** status code is a server error, this should be our programmers feel the most cordial status code, because accidentally produced a bug, the server reported 500 error, common and database connection is not good and so on basically appear 5** status code means programmers may have to work overtime haha.

In a word: server: this.. I was careless, it doesn’t matter!

5** series of status codes commonly used are mainly 500,502,503,504

  • 500 (Internal Server Error) : indicates an Internal Server Error. The server encountered an error that prevented it from continuing service, usually caused by our bugs.
  • 502 (Bad Gateway) : The Gateway is faulty. The Gateway or proxy server fails to execute the request.
  • 503 (Service Unavailable) : When a server is overloaded for a short period of time, this is what happened to the server on Douban Zhihu.
  • 504 (Gateway Timeout) : The Gateway or proxy timed out while waiting for a response from another server.

Error screen

Such errors occur, we programmers can not get rid of the blame, this time generally need to check the server error log, locate the specific error information, and then according to the error information to locate the business logic code or other resources such as connection problems, and then modify the bug to go online again.

conclusion

HTTP status code error screen provides some ideas to us, a status code has a lot of, we just need to know the business has seen the status code, and then to take the problems of screening measures, moreover even has ruled out many a status code, but these are hard to remember, here the author suggest that we are familiar with the status code corresponding English name, Because many status codes as long as according to the English name of a look know what the meaning of.