post vs. put when posting a form

﹥>﹥吖頭↗ 提交于 2019-12-12 10:03:31

问题


When evaluating that a form was submitted, I check that the method was post, not get. I was told this is a good way to know that the form was submitted by clicking the submit button and that it's not just being submitted by a script that's passing the data in the url.

How about the "put" method. It seems very similar to "post". Can it be more or less be used instead of "post" without much loss in the benefits provided by "post"?


回答1:


No.

HTML only supports post and get as form methods, even though HTTP has others.

Even outside the context of an HTML form, the answer is still no as PUT and POST are very different. POST is a generic "Here is some data, do something with it" method, while PUT means "Replace the resource at this URI with this data".




回答2:


If you're doing it for security reasons, GET or POST doesn't matter. Read the Wikipedia article on XSRF prevention: http://en.wikipedia.org/wiki/Cross-site_request_forgery#Prevention




回答3:


there is no different between put and post in security ... but put is not supported in some of service's



来源:https://stackoverflow.com/questions/4117621/post-vs-put-when-posting-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!