CS FundamentalsHardProduct-company placement

A team wants its HTTP API to allow safe retries of PUT /users/42 with the full user body. Which property of PUT makes this safe, and what must the server ensure?

  1. A. PUT is safe (read-only), so the server may ignore it
  2. B. PUT is cacheable, so the second request is served from a cache
  3. C. PUT is neither safe nor idempotent, so retries are never allowed
  4. D. PUT is idempotent: the server must apply it as a full replacement so that sending the same request twice leaves the same state as sending it once

Correct answer: D. PUT is idempotent: the server must apply it as a full replacement so that sending the same request twice leaves the same state as sending it once

Idempotence means repeated identical requests have the same effect as one. Implementing PUT as 'increment a counter' or 'append' would break that contract; it changes state, so it is not safe.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic