• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why put is not considered non-idempotent?

 
Ben Pheonix
Ranch Hand
Posts: 46
1
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a confusion, that we consider post non-idempotent. While we don't consider put non-idempotent. If allowed by the servers, put can change the
state of the server as well. So why put is not considered non-Idempotent?
Thanks,
Ben
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Idempotent" doesn't actually mean that it can't change the state - that's a common misuse of the word. It means that if the operation is made multiple times it has the same effect as making it just once. So, for example, if you have a POST request that creates a new record, then applying it twice will create two records. So that isn't idempotent.

The word for an operation that has no side effects is "nullipotent".

 
Ben Pheonix
Ranch Hand
Posts: 46
1
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Mathew,

Doesn't put come under category of Post as well? If we repeat the operation of put twice, it can also create the same effect as post. Then why not put
considered non-idempotent.

Thanks,
Ben
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Pheonix wrote:Doesn't put come under category of Post as well?

No. A PUT, executed with the same data, will have the exact same effect each time it is executed.

If you're "not looking" and a random number of PUTs occur, then how would you tell how many PUTs occurred while you had the blindfold on? You can't. Because the effect of executing 17 of the PUTs, or 17 million of them, has the exact same effect of executing one PUT.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put should be idempotent. Of course, you can implement it to not be - you can implement GET to be not-idempotent if you want. But you won't be following the HTTP specification.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2532
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

No PUT doesn't have side effects, it just creates a resource once or when PUT is used multiple times (of the same resource) it overrides the resource.

Just check the this part of the HTTP specs.

Regards,
Frits
 
Ben Pheonix
Ranch Hand
Posts: 46
1
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Frits, mathew, bear,

Thank you so much for the help. I am clear on the concept now.

Thanks,
Ben
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic