Web Technology Basics

Among HTTP methods, which of the following is not "safe" (not intended to change the state of resources on the server) but is "idempotent" (sending the same request any number of times leaves the same state as sending it once)?

  1. AGET
  2. BPOST
  3. CPUT
Show answer and explanation

Answer: C. PUT

GET and HEAD are safe methods that only read resources, and safe methods are also idempotent. PUT replaces the state of the specified resource with the content sent, so sending it any number of times gives the same result as sending it once: it is idempotent but not safe. DELETE is likewise idempotent. POST may create a new order or post each time it is sent, so it is generally not idempotent, and PATCH is not necessarily idempotent either. An idempotent request has the advantage that it can simply be resent when a communication failure leaves the result unknown, with little risk of problems.

  • A. GET only reads resources, so it is both safe and idempotent.
  • B. POST may create a new resource each time it is sent, so it is generally neither safe nor idempotent.
  • C. Correct. PUT replaces the resource with the content sent, so any number of sends leaves the same state.
Practice this topic Back to topic

Books on Web Technology Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Web Technology Basics questions

  1. Which of the following correctly pairs an HTTP status code with its meaning?
  2. On a members-only website, an ordinary member who is logged in requests a page that only administrators may access. The server knows who the user is but does not allow access to this page. Which of the following status codes is most appropriate to return?
  3. A web API returns data in JSON format as the body of its response. Which of the following headers is generally added to the response to indicate the format of the body?
  4. A browser requests an image it received earlier once again, putting the ETag value from that earlier response into the If-None-Match header. If the image on the server has not changed, which of the following is the correct server response?
  5. Which of the following correctly describes HTTP/2 and HTTP/3?