开发者

Why can't the browser search POST HTML request's body for the parameters and then bookmark the pages like for GET

POST HTML requests can't be bookmarked but GET ones can be. The reaso开发者_StackOverflow中文版n given is that the parameters are appended in the case of GET whereas they are not in POST. Why can't the browser search POST HTML requests body for the parameters and then bookmark the pages like for GET ?


A POST is meant to update the state of something on the server.

In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.

Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.

Source.

Do you want to bookmark a delete method of a website, etc?


Theoretically speaking — they could.

They shouldn't though, as POST requests are supposed to "request that the origin server accept the entity enclosed in the request as a new subordinate of the resource".

Examples given by the spec are:

  • Annotation of existing resources;
  • Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
  • Providing a block of data, such as the result of submitting a form, to a data-handling process;
  • Extending a database through an append operation.

None of these are repeatable operations, so it doesn't make sense for the browser to store the request in a repeatable fashion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜