gpt4 book ai didi

http - 如果 Web 资源 POST 到自身是否危险?

转载 作者:可可西里 更新时间:2023-11-01 16:19:00 26 4
gpt4 key购买 nike

在阅读一些关于使用 Twisted 编写 Web 服务器的文章时,我遇到了this page其中包括以下声明:

While it's convenient for this example, it's often not a good idea to make a resource that POSTs to itself; this isn't about Twisted Web, but the nature of HTTP in general; if you do this, make sure you understand the possible negative consequences.

在本文讨论的示例中,资源是使用 GET 请求检索的 Web 资源。

我的问题是,将资源 POST 到自身可能会带来哪些负面后果?我只关心与 HTTP 协议(protocol)相关的方面,所以请忽略我提到的关于 Twisted 的事实。

最佳答案

POST 动词用于在集合中创建新资源。这意味着 POST 到资源没有直接意义(POST 端点应始终是集合,而不是资源)。

如果你想更新你的资源,你应该 PUT 到它。

有时,您不知道是要更新资源还是创建资源(也许您已经在本地创建了它并想创建或更新它)。我认为在那种情况下,PUT 动词更合适,因为 POST 的真正意思是“我想创造一些新东西”。

关于http - 如果 Web 资源 POST 到自身是否危险?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9352885/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com