Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return HTTP status code 204 for empty response #104

Closed
rgov opened this issue Mar 16, 2016 · 3 comments
Closed

Return HTTP status code 204 for empty response #104

rgov opened this issue Mar 16, 2016 · 3 comments

Comments

@rgov
Copy link

rgov commented Mar 16, 2016

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?

@rgov 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
@vanHoesel
Copy link

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.

@wsanchez
Copy link
Member

wsanchez commented Oct 4, 2016

Please no.

It is not incorrect for a method to return an empty response body with a status code of 200, so the framework should not be "fixing" that for you.

@rgov
Copy link
Author

rgov commented Oct 5, 2016

Fair enough.

@rgov rgov closed this as completed Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants