You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be sensible to change the status code from 200 OK to 204 No Content without having to explicitly call request.setResponseCode(204) when the response body is empty?
The text was updated successfully, but these errors were encountered:
rgov
changed the title
Should it return HTTP status code 204 for empty response
Return HTTP status code 204 for empty response
Mar 16, 2016
Depending on what the context is, I just stumbled upon this question here...
204 is meant for a specific purpose... Confirm that the request has been understood and could be processed accordingly!
Use it for confirmation of UI actions, like tick boxes that get immediately sent to the backend, star-ratings, row deletions from a table.
204 Also implies that the browser will not update the view.
If however it is a response to a search or a resource that has no children... then return an empty list (how ever that is defined, depending if it is a XML doc or JSON struct) ... if that means an empty word list, then yes, no lines and Content-Length = 0.
But still 200 OK
You do want to have the browser point to the new page with the new result list.
Would it be sensible to change the status code from 200 OK to 204 No Content without having to explicitly call
request.setResponseCode(204)
when the response body is empty?The text was updated successfully, but these errors were encountered: