post vs. put when posting a form

2019-05-23 04:36发布

问题:

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