Objective
After the request is sent on the network, it is often judged by the request's status code that the successful failure or not, the common status code is 200,404,500.
But do you think there are only so many status codes for HTTP requests? is actually much more than this.
Let's take a look at the status codes commonly used in HTTP requests today in this article.
HTTP status Code
2xx-Request succeeded
The status code for the 2XX class starting with 2 indicates that the request was successful and the server performed the requested operation correctly. For example, a POST request, the data sent in the request body is handled correctly by the server, such as a write database operation.
In the 2XX class status code, the most common is 200, at least if I have not seen a successful request, the status code is not 200. So we just need to know the meaning of the 200 status code representation.
Status Code 200
3xx-redirection
The status code for the 3XX class starting with 3 indicates that the request is redirected, and the server returns information telling the browser how to perform the subsequent operation to successfully process the request.
Let's look at some of the 3XX status codes that need to be mastered.
The 301 status code represents a permanent resource redirect, such as requesting resource A's URI-A1, but the server side returns 301, and a new URI-A2 is specified, which means that resource A is requested later, and only URI-A2 is used.
Status Code 301
The 302 status code represents a temporary redirection of resources, such as requesting resource A's URI-A1, but the server side returns 301, and a new uri-a2 is specified, where the location of the resource is temporarily represented by URI-A2 and may be changed later, so this uri-a2 is not permanent.
Status Code 302
The 303 status code indicates that the resource you need is found on the server, but there is another URI for the resource, and you want the client to use the Get method in subsequent requests to request the new URI that is returned.
Status Code 303
4xx-Client Error
The status code for the 4XX class starting with 4 indicates a client error.
401 indicates that the server needs the client to provide some authentication information, if the authentication does not pass, it will not be able to send the request. In particular, this situation occurs when the browser first sends the request, the server side needs the client authentication information, the most intuitive information will be in the browser pop-up an input box, users need to fill out the authentication information.
Status Code 401
403 means the server side refuses to accept the request sent by the client, and generally does not give the reason why, and why to give a refusal.
However, this is usually caused by user access without permission. In the course of my work, I often encounter 403 of problems, because we have strict rights management interface, if the new interface does not correctly configure permissions, it will cause 403 problems.
Status Code 403
404 is probably the most familiar status code for all programmers, without too much description, that is, the requested resource does not exist on the server side, generally the URL of the request is not correct.
Status Code 404
405 means that the requested URL is recognized by the server, but is not allowed to use the method.
It is important to note that theget and head methods are always allowed to execute on the server side.
A common reason for the presence of a 405 status code is when the service-side definition of the request type is inconsistent with the type sent by the client, such as the server-side defined method is post, and the client send request type is get.
5XX Server-side error
A 5XX type status code starting with 5 indicates a server-side error.
A 500 status code represents an internal execution exception in the server, which generally manifests itself as a bug on the program, such as when code throws an exception during execution, such as a common null pointer.
Status Code 500
502 Status codes typically show information about bad gateway type error gateways.
Mainly due to the client to the server-side request time-out, such as in the case of poor server-side network conditions, while a number of clients to the server side of the request, will cause the server side resources are not enough to respond normally, will return this result.
Generally the simplest solution is the way to refresh, there are many because of the cache situation, directly from the local data, will not be reported 502 error.
The 503 status code indicates that the server is unable to process the request, typically in a server outage or in an overloaded state. However, this is generally a temporary situation where the service continues to be available after a service restart or load balancing process.
Status Code 503
504 Status Code General gateway during the forwarding process, the response of the upstream server has not yet been received over the set time.
Conclusion
Today this article mainly introduces some commonly used HTTP status code, these status codes will often be used to judge the availability of services, but also very convenient for the front and back end of the error judgment, we have to master ~
Turn from
https://www.toutiao.com/i6496464659028115981/
What are the typical HTTP status codes that you only know about 404? Come on, let's go.