Is REST DELETE really idempotent?

后端 未结 8 2307
一生所求
一生所求 2020-11-30 18:43

DELETE is supposed to be idempotent.

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

If I do it again would I expect a 404, sin

8条回答
  •  眼角桃花
    2020-11-30 19:22

    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.

    From 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. "


    The key bit there is the side-effects of N > 0 identical requests is the same as for a single request.

    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.

提交回复
热议问题