Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does idempotency include response codes?

Do repeated requests to idempotent methods have to return the same response code?

A lot of other people are asking the same question and ending up with contradicting answers. The answer should reference an authoritative source on the matter.

like image 892
Gili Avatar asked Jul 12 '14 14:07

Gili


People also ask

Which of the following method is not idempotent?

Implemented correctly, the GET , HEAD , PUT , and DELETE methods are idempotent, but not the POST method.

What is the difference between idempotent and non idempotent?

Non-idempotent (PUT,POST,DELETE) methods change the data which is used to populate content in the web pages or effect change elsewhere (such as moving a crane, transferring funds, sending an email). That's not entirely correct. Idempotent means that you can repeat the request and the result should be the same.

What are idempotent methods in HTTP?

Idempotency means that multiple identical requests will have the same outcome. So it does not matter if a request is sent once or multiple times. The following HTTP methods are idempotent: GET, HEAD, OPTIONS, TRACE, PUT and DELETE. All safe HTTP methods are idempotent but PUT and DELETE are idempotent but not safe.

What are idempotent methods in REST?

An idempotent method means that the result of a successful performed request is independent of the number of times it is executed.


1 Answers

I asked this question on the HTTP mailing list and was told that idempotency does not include return codes. Meaning, you are free to return HTTP 204 the first time a resource is deleted, and HTTP 404 at a later time, so long as the subsequent request does not change the server state.

While it is true that subsequent requests may not change the server state, the response codes are not considered part of that state.

like image 69
Gili Avatar answered Oct 06 '22 13:10

Gili