Http Requests POST vs GET

后端 未结 4 1280
清歌不尽
清歌不尽 2020-12-19 23:02

I am using a lot of HTTP Requests in an application that I am writing which uses OAuth. Currently, I am sending my GET and POST requests the same way:

HttpCo         


        
4条回答
  •  不知归路
    2020-12-19 23:28

    Use POST for requests that modify something, GET for requests that do searches or simply get documents. The difference on the browser side is that browsers avoid accidentally doing a POST request again e.g. by prompting the user for confirmation.

    When processing a POST request, never respond with a document, but instead redirect the user to a GET request that contains the "form submitted" or whatever answer you want to give. This avoids problems with browser back/forward buttons because otherwise browsing to the response page would require resubmitting the POST request.

提交回复
热议问题