http - REST DELETE 真的是幂等的吗?

标签 http rest http-headers

DELETE 应该是幂等的。

如果我删除 http://example.com/account/123它将删除该帐户。

如果我再做一次,我是否会收到 404,因为该帐户已不存在?如果我试图删除一个从未存在过的帐户怎么办?

最佳答案

幂等性是指请求完成后系统的状态


在所有情况下(错误问题除外 - 见下文),该帐户不再存在。

来自 here

"Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent. "


关键是 N > 0 个相同请求的副作用与单个请求相同。

您期望状态代码会有所不同是正确的,但这不会影响幂等性的核心概念 - 您可以多次发送请求,而无需对服务器状态进行其他更改。

关于http - REST DELETE 真的是幂等的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4088350/

相关文章:

android - vpn 以编程方式 android

rest - 什么是 REST API 入口点,它与端点有何不同?

http - 如何处理接受语言回退?

c# - .NET HTTP POST 方法 - Cookie 问题

asp.net - 在 ASP.Net 中编写自定义 NTLM 质询/响应

rest - 什么是其余 API 方法 - COPY、HEAD、OPTIONS、LINK、UNLINK、PURGE、LOCK、UNLO​​CK、PROPFIND、VIEW

javascript - 在 NodeJS 中根据内容长度查找视频时长

c# - 在 WP7 中发出 http post 请求发送 JSON 文件

linux - 如何为服务器上的文件创建可下载的公共(public)链接

c# - DataContract 不使用属性中指定的名称属性