Four new HTTP Status Codes

Source: Internet
Author: User


Four new HTTP status codes RFC 6585 have just been released. This document describes four new HTTP status codes. Is the HTTP protocol www.2cto.com 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-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 client Requests for a service, that is, the request speed limit. Before that, www.2cto.com had some similar status codes, such as '509 Bandwidth Limit exceeded '. twitter uses 420 (this is not the HTTP-defined status code). If you want to limit the number of client requests to the service, you can use the 429 status code, it also contains 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, the client may send a Large HTTP Request Header, the server can send the 431 Request Header Fields Too Large to indicate the problem. 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 (requiring Network Authentication) this status code is very interesting for me. If you are developing an HTTP server, you do not have to process this status code, however, 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 "intercept" clients at www.2cto.com 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, and 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. Author sweet potato

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.