• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why HF says PUT is idempotent ??

 
Raju Sri
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

As per Java Docs below is the description for doPut() method.
###############################################################
This method does not need to be either safe or idempotent. Operations that doPut performs can have side effects for which the user can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage.
#################################################################

I think only GET and HEAD methods are idempotent.PUT is not idempotent.

Can some body please confirm me this in exam point of view.

Thanks
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raju,

You're right. PUT is not idempotent.

Are you refering to pg 114 of HF that states that PUT is idempotent along with GET & HEAD? If you're, don't worry, its a typo. Its also under the official errata. In a thread somewhere in this forum, Kathy had confirmed that PUT is not idempotent & pg 114 contained a typo.

HTH.
 
Raju Sri
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cheng,

Thanks for your confirmation that PUT is not idempotent. Actually I am refering to the mock exam question on HF page 145 .The answer for question 4 should be B and D. The question is asking which methods are not idempotent?. So answer B(POST) and D(PUT) should be correct . But HF says only B is correct.Am I correct ?

Cheers
Raju
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju,

To save yourself from more headaches, have a look at:
http://www.oreilly.com/catalog/headservletsjsp/errata/
and update your book with what everyone else has found for you!
 
satguru srivastava
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roger,
The errata only refers to POST not PUT.
I think PUT should be idempotent.
No matter how many time the PUT request is sent the result would always be the same viz resource is stored at the location specified.
Right ?
Thanks
Satguru
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju,

The HTTP1.1 spec says the following:
9.1.2 Idempotent Methods

Methods can also have the property of "idempotence" in that (aside
from error or expiration issues) the side-effects of N > 0 identical
requests is the same as for a single request. The methods GET, HEAD,
PUT and DELETE share this property.
Also, the methods OPTIONS and
TRACE SHOULD NOT have side effects, and so are inherently idempotent.

However, it is possible that a sequence of several requests is non-
idempotent, even if all of the methods executed in that sequence are
idempotent. (A sequence is idempotent if a single execution of the
entire sequence always yields a result that is not changed by a
reexecution of all, or part, of that sequence.) For example, a
sequence is non-idempotent if its result depends on a value that is
later modified in the same sequence.

A sequence that never has side effects is idempotent, by definition
(provided that no concurrent operations are being executed on the
same set of resources).


I guess this is what we will be tested on
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic