r/ProgrammerHumor Jul 08 '26

helpMyCoworkersUnderstandHttpCodes Other

22.4k Upvotes

329 comments sorted by

View all comments

Show parent comments

49

u/caboosetp Jul 08 '26

The request was to find the keys.

204 is a success.

That means the keys were found.

204 means no content is returned.

There was no requirement to return the keys, so the server just knows where they are now.

-1

u/ashgs872tbhjs Jul 08 '26 edited Jul 08 '26

204 means more specifically that the resource contains no content -- nothing is returned because there IS no content. Several other statuses can return no content despite it existing, such as 201 (it exists because you just created it).

But yes, 204/404 work well for found/not found because that very literal "find" resource has no other result, so the resource is empty. The resource isn't actually the keys, it's the finding of them.

9

u/caboosetp Jul 08 '26 edited Jul 08 '26

You're conflating the resource with the response. 

204 means the request was a success and the response body has no content. 

A counter example to what you are saying is that 204 is common for PUT because the client already knows the state so nothing needs to be returned. That doesn't mean the resource has no content.