REST DELETE真的是幂等的吗? [英] Is REST DELETE really idempotent?

查看:469
本文介绍了REST DELETE真的是幂等的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DELETE应该是幂等的。

DELETE is supposed to be idempotent.

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

If I DELETE http://example.com/account/123 it's going to delete the account.

如果我再次这样做,我会期望404,因为该帐户不再存在?如果我尝试删除从未存在过的帐户怎么办?

If I do it again would I expect a 404, since the account no longer exists? What if I attempt to DELETE an account that has never existed?

推荐答案

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




Idempotence refers to the state of the system after the request has completed


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

In all cases (apart from the error issues - see below), the account no longer exists.

来自此处


方法也可以具有
idempotence的属性(除了
错误或到期问题
)N> 0个相同的
请求的
副作用与单个
请求的相同。方法GET,HEAD,PUT
和DELETE共享此属性。另外,
方法OPTIONS和TRACE应该是
没有副作用,因此
本身也是幂等的。

"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个相同请求的副作用与单个请求相同。

您希望状态代码不同但这不会影响幂等性的核心概念是正确的 - 您可以发送超过一旦没有对服务器状态的其他更改。

You would be correct to expect that the status code would be different but this does not affect the core concept of idempotency - you can send the request more than once without additional changes to the state of the server.

这篇关于REST DELETE真的是幂等的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆