• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Why put is not considered non-idempotent?  RSS feed

 
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
 
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
 
Marshal
Posts: 67163
169
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.
 
Creator of Enthuware JWS+ V6
Posts: 3178
276
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!