Junior — Middle
Kas saaksid anda näiteid idempotentsetest HTTP-päringutest?
sobes.tech AI
Vastus AI-lt
Idempotent HTTP requests are those that, when repeated, do not change the state of the server after the first call.
Examples of idempotent HTTP methods:
- GET — retrieve a resource. Repeated requests do not modify data.
- PUT — update a resource. Sending the same PUT multiple times results in the same state.
- DELETE — delete a resource. Repeated DELETE calls on the same resource do not change the state (the resource is already deleted).
- HEAD — similar to GET, but without a response body, also idempotent.
Example:
PUT /users/123 HTTP/1.1
Content-Type: application/json
{"name": "Иван"}
Sending this request multiple times will result in the user with id 123 having the name "Иван" — the state does not change after the first request.