Document directory
- 428 precondition required (prerequisite required)
- 429 too required requests (too many requests)
- 431 request header fields too large (the request header field is too large)
- 511 Network Authentication required (Network Authentication required)
RFC 6585 has just been released. This document describes four new HTTP status codes.
Is the HTTP protocol still changing? Yes, the HTTP protocol has been evolving. The new status code is very useful for developing rest services or HTTP-based services, the following describes in detail the four new status codes and whether they should be used.
428 precondition required (prerequisite required)
A prerequisite is that when the client sends an HTTP request, some Preset conditions must be met if the request is successful.
A good example is the IF-None-match header, which is often used in GET requests. If if-None-match is specified, then the client will receive the response again only after the etag in the response changes.
Another example of the prerequisite is the IF-match header, which is generally used on put requests to indicate that only resources that have not been changed are updated, this is used when multiple clients use the HTTP service to prevent the same content from being overwritten by each other.
When the server uses the 428 precondition required status code, it indicates that the client must send the above request header to execute the request, this method provides an effective method for the server to prevent the 'lost Update' problem.
429 too required requests (too many requests)
This status code is useful when you need to limit the number of services requested by the client, that is, the request speed limit.
Before that, there were some similar status codes, such as '509 bandwidth limit exceeded '.
Twitter uses 420 (this is not a status code defined by HTTP)
If you want to limit the number of client requests to the service, you can use the 429 status code and contain a retry-after response header to tell the client how long it will take to request the service again.
431 request header fields too large (the request header field is too large)
In some cases, when the client sends an HTTP request header, the server can send
431 request header fields too large to specify this issue.
I don't know why I didn't have a 430 status code. Instead, I jumped from 429 to 431. I tried to search but there was no result. The only guess is that 430 forbidden and 403 forbidden are too similar. They do this to avoid confusion. God knows!
511 Network Authentication required (Network Authentication required)
This status code is very interesting for me. If you are developing an HTTP server, you do not have to handle this status code, but if you are writing an HTTP client, this status code is very important.
If you frequently use laptops and smartphones, you may notice that a large number of public WiFi services require you to accept certain protocols or log on before using them.
This is because HTTP traffic is intercepted. when a user attempts to access the network and returns a redirection and logon, this is annoying, but the actual situation is as follows.
Using these "blocking" clients has some annoying side effects. These two examples are mentioned in RFC:
- If you access a website before you log on to wifi, the network device will block the first request. These devices often have their own website icon 'favicon. ICO '. After logging on, you will find that the website icon you visit for a period of time has always been the icon of the WiFi login website.
- If the client uses an HTTP request to find the document (which may be JSON), the Network will respond to a logon page, so that your client will parse the error and cause the client to run abnormally, in reality, this problem is very common.
Therefore, the 511 status code is proposed to solve this problem.
If you are writing an HTTP client, you 'd better check the 511 status code to confirm whether authentication is required before access.
Original English, oschina Original translation