Explanation of http status codes

  For web programmers, http is definitely a more important place. This chapter talks about the status code of http. PS: For a detailed understanding of the http part, it is recommended to read the "http authoritative guide", which is the bible. For http, but if you are a novice and are not very familiar with this part, my suggestion is to read "Illustrated HTTP" first, and then read The Definitive Guide. I wrote this piece with reference to the graphic http.

  http status code

  1. Category

    

   category  illustrate
 1xxx  informational (informational status code)  request is requesting
 2xxx  success  The request is processed normally
 3xxx  redirection  Additional action is required to complete the request
 4xxx  client error (client error status code)  The server was unable to process the request
 5xxx  server error (server error status code)  Error processing request by server

  The categories are the above, and the following is a detailed description of each status code

  2. Detailed explanation of status code

    At present, there are a lot of status codes. I will talk about the commonly used ones here.

    200 ok, this is not to say, it means that the request is completed, but there are still some differences for each http method, such as get is the request entity will be returned, but if the head method is used, the response will only return the header

    204 no content , this indicates that the request is also successful, but it does not contain the entity body part, and it is not allowed to return the entity part. It is generally used by the client to send information to the server, but does not need to send new information to the client.

    206 partial content, this is special, it belongs to a part of the request for resources, this is used for things like pictures. Last time I requested a part of it and it suddenly broke, this time I only need the second half and so on, but this requires Add content-range to illustrate

    301, 302, 303, 307, these are actually redirects, but there are differences. Generally, 301, 302, 301: means permanent redirection, 302 means temporary redirection,

303 and 307 seem to be variants of 302. They are used less often, and I have not encountered many times. To briefly explain the difference, 303 means that you want to use get to obtain resources (I don’t know if everyone follows this rule), 307 will not change from post to get according to browser requirements, and 301 and 302 clearly indicate that you do not want to change from post to get access

    There is also a 304 that needs to be explained. 304 has nothing to do with redirection. It means that access to the server is allowed, but if it is not satisfied, no entity is returned.

    400 bad request, generally returned means that the server cannot understand the request, it should be an error, and the client needs to modify the content and send it

    401 unauthorized, which means no permission and requires authentication. Generally, this method is sometimes used when I write rest API.

    403 forbidden, which means that it was rejected by the server. Generally, it will not give you the reason, but if you want to, it will be written in the returned entity.

    404 not found, let's not talk about this

    500 internal server error, this is not to say

    503 service unavailable means that the server is temporarily unavailable, shut down for maintenance, etc., but if you know when to recover as a backend, it is better to add RetryAfter to the returned entity

  It is often encountered that the status code and the status are inconsistent, and this needs to be judged by yourself. . Finally, Amway is a tool. If you only want to see statusCode, there is an extension under Google called Http Status. .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324726171&siteId=291194637