-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Enable returning 204 No Content #645
Comments
I've renamed this to "Enable returning 204 No Content". See #618 for a possible solution, still looking forward to a PR. |
I do not want to serve a text/plain response to a request that expects a json response (http://.../foo.json). An empty string, not being valid json, also won't work. |
I don't know if I will be the person sending requested PR, but, do you care what the api for this functionality looks like? |
So, if you want to return valid JSON, you should return I really don't have a strong opinion of what the API looks like, but I can comment when I see a suggestion :) |
I chose @body = nil
status 204 |
I realize this is closed, but I wanted to share an issue I just ran into the hard way.
Reason being that, it would seem, the Rack spec does not precisely follow HTTP spec. There is some dissent on the matter, as seen in a related issue (no content-type for empty body) here: But the spec states:
https://github.com/rack/rack/blob/master/SPEC#L244-L248 This just came up, I'll be solving it tomorrow, I suspect I hope this helps someone else. edit: here's a related StackOverflow discussion: |
My question in rack#472 remained unanswered btw. |
@dblock oh, haha, I hadn't even noticed that was you. Now I'm not sure if I'm right about this, turns out I had a bigger issue going on - has this been your experience, do I need to return |
I guess the answer is "I am not sure"... |
The issues mentioned above looks unrelated first,
From the perspective of Grape user, you should use |
as for
I agree, the spec says
and
so it looks like the semantics of 405 response does not assume any resource representation |
In (some of) my case(s), returning an empty array or hash is the more appropriate than a string - it's a case where I was returning a nil body and a 204 where I might otherwise be returning a collection. An empty collection would make sense there. Other cases, yeah, I guess an empty string is an ok substitute for As for grape converting a |
Per the readme, a formatter must supply a content type. However, when sending an empty response body, no content type is wanted at all.
Related issue is #215. As far as I see even with my own formatter I cannot return empty response bodies/204 no content.
The text was updated successfully, but these errors were encountered: