Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why PUT is idempotent ?

 
Edisandro Bessa
Ranch Hand
Posts: 584
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

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.

TIA,
Edisandro Bessa.
[ October 05, 2006: Message edited by: Edisandro Bessa ]
 
Holger Kraus
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Edisandro,

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.

Best regards

Holger
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic