In HFSJ book the authors say that GET, HEADER and PUT are idempotent.
I'm really aware regarding the GET and HEAD methods but why PUT is also idempotent ?
I think I must first understand what's the PUT purpose.
As per my understanding, PUT is used to literally put some file on the server. Is it correct ?
If PUT is idempotent, is DELETE as well ?
Could you please explain which are idempotent ?
GET : Idempotent POST : Non-Idempotent HEAD : Idempotent PUT : Idempotent. Why ??? DELETE : I really don't know. I think it's not idempotent. Please explain. TRACE : Idempotent OPTIONS : Idempotent CONNECT : I really don't know. I think it's idempotent. Please explain.
I think the mathematical definition of idempotence from wikipedia helps: "A unary operation (i.e., a function), is idempotent if, whenever it is applied twice to any element, it gives the same result as if it were applied once."
If you put a file to the server, the file will only be there once, even if you perform the PUT more than once. => idempotent
Its the same with DELETE. If you have deleted a file on the server, a second delete will have the same result: Theres is no file with the name of the deleted one. => idempotent
If you send an order to an online-shop by using POST, a second POST will imply a second order, so the result is not the same. So the result is not the same. => not idempotent
All other methods are idempotent, too.
I hope, that helps.
--<br />SCJP<br />SCJD<br />SCWCD
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad: