HTTP status codes have not been thoroughly researched.

These days when the group is on duty always listen to seniors mentioned interview, also incidentally searched some legends of the face by…. Found that the gap is still quite big, and even the problem of the status code has not been summed up in order to prove that they have done a programmer…………. Just re-record it

Most of them are illustrated HTTP notes

An overview

The HTTP status code is responsible for representing the return result of the HTTP request from the client, marking whether the processing of the server is normal, and informing the error. The working status code consists of three digits. The first digit represents the cause classification, and the remaining two digits have no special classification

type category why
1XX Informational (Informational status code) The accepted request is being processed
2XX Success (Success Status code) The request is successfully processed
3XX Redirection (Redirection status code) Additional action is required to complete the request
4XX Client Error (Client Error status code) The server cannot process the request
5XX 5XX Server Error (Server Error status code) Server processing request error

There are about 14 common ones

2XX

200 OK

This status code is probably the most common one we want to see. The request sent on behalf of the client is normally processed by the server and in the response message. The information returned with the status code varies with the HTTP method

The common request methods are GET and POST, but not only these two, there are usually eight methods: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, and CONNECT

204 No Content

This status code means that the request sent by the client is processed by the server but the server does not return any physical content

This is usually used when only information needs to be sent from the client to the server, and no new information content needs to be sent to the client

206 Partial Content

This status code indicates that the client has made a Range request and the server has successfully executed this part of the GET request. The definition of 206 is that the request must contain the Range header to indicate the desired Range

So this means we can block a large file with Range and 206 Partial Content

3XX

301 Moved Permanently

Permanent redirection

This status code indicates that the requested URL resource has been assigned a new URL. If the resource’s URI has been bookmarked but the new URL is given in the Location header, the browser should automatically save and access the new URL

302 Found

Temporary redirection

From the general description, we can see that this status code is similar to 301 except that the status code is temporarily assigned to the new URL. The new URL should be used in this visit without updating the bookmark

303 See Other

This status code also indicates the presence of a new URL, but it should be noted that this status code explicitly states that the client should use the GET method to obtain the resource

For example, when a CGI program is accessed using POST and the result is that the client is expected to redirect to another URI using GET, the 303 status code is returned. While the 302 Found status code can do the same thing, the 303 status code is ideal here

304 Not Modified

This status code indicates that when a client sends a conditional request, the 304 status code returns a body that does not contain any response and the server tells the client that the original buffered document can be used again. 304 is classified in the 3XX category, but has nothing to do with redirection

For example, on a web page that contains if-Modified, the server automatically compares Last Modified to If Modified Since, performs caching or updating, while on a dynamic page, Last Modified is defined in the message header, resulting in this result

First access 200 Click Second Access (Cache) Press F5 to refresh 304 Press Ctrl+F5 to forcibly refresh 200

A conditional request packet that uses the GET method contains any of if-match, if-modifiedSince, if-none-match, if-range, or if-unmodified-since headers

307 Temporary Redirect

Temporary redirection

This status code has the same meaning as 302, but is not stated above

When the 301, 302, and 303 response status codes return, almost all browsers change POST to GET and delete the body of the request message, and the request is automatically sent again. 301, 302 Standard forbids changing POST to GET, but in practice people still do so

This 307 is a little bit more compliant, and it’s going to follow the browser standards and not change from POST to GET

4XX

400 Bad Request

The status code indicates that a syntax error exists in the request packet. When an error occurs, you need to modify the content of the request and send the request again

401 Unauthorized

The status code indicates that the request must be authenticated through HTTP (BASIC authentication or DIGEST authentication). In addition, if the request has been made once before, the user authentication fails

403 Forbidden

This status code is also common. It indicates that the resource that is trying to access is forbidden to access. The file system is not authorized to access the resource, and some access permission problems occur (unauthorized source IP addresses attempt to access the resource)

404 Found

Another common status code that indicates that the server does not have this resource or that the server has rejected you ruthlessly, but does not want to tell you why

The main thing I see in Python development is 404 caused by undefined routes

5XX

500 Internal Server Error

This status code indicates that an error occurred on the server side while executing the request. It could also be a Web application bug or some temporary glitch

As the official explanation goes, a common problem in development is code errors, at least in my case

503 Service Unavailable

This status code indicates that the server is overloaded or down for maintenance and cannot handle requests

About status codes and responses

Many of the status code responses returned are incorrect, but the user may not be aware of this. It is not uncommon for the status code to return 200 OK after an error occurs within a Web application

What does Not Modified status code 304 mean