http status code 204 understand


There are many kinds of HTTP status codes, mainly 1xx (temporary response), 2xx (success), 3xx (redirected), 4xx (request error) and 5xx (server error) five categories, each category also corresponds to some specific categories. Usually we have more contact with 200, 400, 500 and so on.

 Here we mainly discuss the status code 204. The description of 204 in HTTP RFC 2616 is as follows:
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent’s active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent’s active view.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, Although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
It means that the request is executed successfully, but there is no data, the browser does not need to refresh the page, nor does it lead to a new page. How to understand this sentence. Let’s use an example to illustrate. Suppose there is a form on the page, the submitted url is http-204.htm, and the form is submitted. Under normal circumstances, the page will jump to http-204.htm, but if http-204.htm The corresponding status code is 204. At this time, the page will not jump, and it will stay on the current page. In addition, for the a tag, if the response code of the linked page is 204, the page will not jump.

Therefore, for some data submitted to the server for processing, if it is only necessary to return whether it is successful, you can consider using the status code 204 as the return information, thereby saving redundant data transmission.

From:  http://www.netingcn.com/http-status-204.html

Guess you like

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