Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(idempotent (GET, HEAD, etc)/NON idempotent(POST, PUT, etc.)

 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between idempotent (GET, HEAD, etc) and NON idempotent(POST, PUT, etc.) ???

can anybody help me
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My guess is that you are really asking what idempotent really means.
www.dictionay.com -> idempotent
Acting as if used only once, even if used multiple times


What this really means is the methods GET, HEAD, etc should not make changes that will cause a second identical request (for the same user in the same session) to display different information, ie update the database.

Methods such as Post and PUT are not expected to be idempotent, that is two identical requests (from the same user in the same session) may result in different results being displayed to the user.

To put this another way adding an item to a shopping cart is not an idempotent request as it changes information curical to the user. Where as viewing the contents of the shopping cart should not change the contents of the shopping cart as it therefore an idempotent request.

Hope this helps

Mat
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks williams
 
Aruneesh Salhotra
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read in the book, that POST was the only idempotent HTTP METHOD type.

I am not sure if PUT is also idempotent.
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure why I added Put - it is an idempotent method (or its supposed to be)

see this for the w3c take on idempotent methods
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Mat
 
Aruneesh Salhotra
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logically speaking,
all POST, PUT and DELETE should be idempotent, but from the perspective of the certification, possibly the book assumption should be correct.

PUT and DELETE could have effect, like putting a file or deleting a resource. The second time you do the same operation, it would possibly throw a warning that either resource is already present or not there.
 
Alexandre Cervieri
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Considering PUT and DELETE, reading the page Mat Williams mentioned make me think that the server should not warn the user if the file to be PUT is already there or the file to be DELETEd is not there anymore. It should be transparent because these methods are also considered idempotent.

I think that for GET and HEAD we have an agreement that they are idempotent. Request a HEAD the N-time for a file should have the exactly result that requesting the HEAD for the same file at the first time.

However, about POST, I don't agree with you. POST is not idempotent. For example, if you have a HTML Form for insert a person in the database. The first time you submit the form that record will be inserted in the database. The second time you submit the form you will get a duplicate key exception (or something like that). And we may find other similar examples.
Regars,
Alexandre
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic