GET 或 POST 进行删除

发布于 2024-12-04 23:41:14 字数 428 浏览 2 评论 0原文

作为网络开发领域的新手,我有一些关于网页设计的常见问题,这是其中之一。

我正在努力为我的网站实现一个简单的地址簿。它应该允许用户添加/修改/删除地址。对于删除,我不清楚应该如何实现它。我应该使用 GET 还是 POST 将删除所需的信息传递到服务器?

我认为使用 POST 进行删除更安全,但亚马逊的实现似乎与此相反(如下)。我对采取哪种方法有点困惑,或者这是否重要?

亚马逊地址删除方法

http://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&addressID=xxxxx&addressDelete=true&sessionId =xxx-xxxxxxx-xxxxxxx

注意:这是一个网站(不是网络服务)

As a newbie in the world of web development, I have a handful of general questions regarding web design and here is one of them.

I am working on implementing a simple address book for my web site. It should allow users to add/modify/delete address. For delete, I am not clear on how I should implement it. Should I use GET or POST to pass the required info for deletion to the server?

I thought it was more secured to use POST for deletion, but when Amazon's implementation seems to counter that (below). I am kind of confused on which approach to take, or does it even matter?

Amazon's approach for address deletion

http://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&addressID=xxxxx&addressDelete=true&sessionId=xxx-xxxxxxx-xxxxxxx

Note: This is for a web site (not a web service)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-12-11 23:41:14

它是 RESTful Web 服务还是只是从浏览器访问的网站?

  • 对于 RESTFul 服务,DELETE 是合适的;
  • 对于网站,只需 POST。

Is it RESTful web service or just a web site accessed from the browser?

  • For RESTFul service DELETE would be apropriate
  • For a web site just POST.
百思不得你姐 2024-12-11 23:41:14

您将使用的 HTTP 方法不会以任何方式影响安全性。它们具有语义意义。您知道还有一个 DELETE 方法吗? POST 和 GET 经常在 Web 应用程序中使用,因为它主要受某些语言(例如 PHP)和浏览器的支持。

还有其他事情您应该注意。在这种情况下,当然,请求已获得授权,您可能会根据您使用的平台使用身份验证系统来解决该问题。

还要警惕诸如 CSRF 之类的事情。例如,某人可以在互联网上发布链接到删除 URL 的虚假图像,登录用户将访问该图像并在不知不觉中删除该实体。这适用于您的应用程序发出的任何请求。

The HTTP method you will use does not affect security in any way. They have a semantic meaning. Did you know there is a DELETE method as well? POST and GET is often used in web applications because it is primarily supported by some languages (e.g. PHP) and browsers.

There are other things you should take care of. In this case, that the request is authorized of course, you will probably solve that with an authentication system depending on what platform you use.

Be also wary of things like CSRF. e.g. somebody could post a bogus image on the internet linking to the delete URL and a logged in user would access it and delete the entity unknowingly. This applies to any request made your app though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文