News for hackers. Stuff that matters.
Re:Developers don't understand CORS (2019) by stymaar on Sunday June 21, 2026 @11:07AM (#48619579)
I wasn't aware of the distinction between “safe” and “idempotent”, TIL, thank you.

> DELETE is not defined to be safe but it is defined to be idempotent

This one puzzles me though. How can DELETE be idempotent? If the first request works then the second one should return a 404, as the key to delete doesn't exist anymore.

Re:Developers don't understand CORS (2019) by JimDabell on Sunday June 21, 2026 @11:37AM (#48619844)
HTTP requests are not RPC calls. The end state of a DELETE request is that the resource does not exist. If you make the request once, the end result is that the resource does not exist. If you make the request twice, the end result is that the resource does not exist. The spec. allows for the actual response to differ; the important thing is that the state is the same regardless.
Re:Developers don't understand CORS (2019) by gbuk2013 on Sunday June 21, 2026 @11:15AM (#48619674)
Response is implementation detail: a 404 on second request is one way to do it, a 202 would be another, or 200 with some sort of response to distinguish (e.g. { changed: boolean }).

Idempotency just means no state mutation on subsequent request.

Re:Developers don't understand CORS (2019) by stymaar on Sunday June 21, 2026 @11:53AM (#48619964)
> 202 would be another

Then you'd return 202 on a request to delete any invalid element, which really doesn't sound right.

> 200 with some sort of response to distinguish (e.g. { changed: boolean }).

Sounds even worse, and much like APIs that returns 200 with a payload saying {error:"not found"}

Re:Developers don't understand CORS (2019) by jaapz on Sunday June 21, 2026 @02:25PM (#48621300)
Request failed successfully
Re:Developers don't understand CORS (2019) by locknitpicker on Sunday June 21, 2026 @03:04PM (#48621637)
It's the graphql way.
Re:Developers don't understand CORS (2019) by gbuk2013 on Tuesday June 23, 2026 @03:48AM (#48641683)
Not really, more like succeed without having to do anything.

The key is the perspective of what success is: it’s the state where the resource does not exist, or is the action having deleted the resource. But 200/202 is perfectly capable of expressing the distinction in the latter case as well.

Re:Developers don't understand CORS (2019) by gbuk2013 on Sunday June 21, 2026 @02:50PM (#48621508)
> Then you'd return 202 on a request to delete any invalid element, which really doesn't sound right

It depends on your use-case if you care about this or not. If you do care you will have to handle it either way somehow.

But if you want an idempotent API then a success is more appropriate IMO than an error.

Re:Developers don't understand CORS (2019) by locknitpicker on Sunday June 21, 2026 @03:04PM (#48621631)
> This one puzzles me though. How can DELETE be idempotent?

It's the textbook definition of idempotence. So much so that wikipedia's article on idempotence mentions it and provides links to primary sources.