-
Notifications
You must be signed in to change notification settings - Fork 118
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
noData() sends invalid response #365
Comments
Interesting perspective, thanks for sharing. I've had the same problem and didn't think it was the header causing it but rather that the ajax library I was using as my REST client was not handling the response appropriately. I suppose it does make some sense that when the response body is empty the Content-Type header should be something else. Any suggestion about what it should be? Perhaps |
Would the right answer be to omit the content-type header entirely? or is that required? |
I'm not sure about technical requirements but to me it's common sense that if there's no content, there should be no content-type header. |
It might help to see how Frisby decides whether to automatically parse JSON https://github.com/vlucas/frisby/pull/412/files. |
I was also wondering about this (small) issue. It is interesting how Frisby is dealing with this. Also, for the record, could be a good thing to change the function name from noData() to noContent(), with a backward compatibility of course. But then, there is the documentation and so on to be modified... |
All sounds good to me. PR's welcome. :) And there is a process for docs PR's too. ;) |
Well, I think I have time for this one, I'll do it, will be my xmas gift ;-) |
@adeleusiere can't assign to you without adding you as a committer, but we can let this comment stand in for assignment. Please consider it yours unless otherwise stated. :) |
Well... I made the change to have a 204 HTTP status code. But to omit the Content-Type header, it's not a piece of cake. I don't find a solution, even by looking at the underlying Tomcat ResponseFacade (https://tomcat.apache.org/tomcat-8.0-doc/api/index.html).
Is someone has an idea how to force that? Otherwise, I would propose to set the Content-Type to |
Calling
return noData()
still sends anapplication/json
content type header with the response, even though the body does not contain valid JSON. This causes a client that expects valid JSON to choke on the response. I am therefore unable to use the noData() function, and have to do this insteadreturn representationOf({})
so that an empty response is still valid JSON. Maybe noData() should either send a valid empty JSON object, or theapplication/json
header should not be sent.The text was updated successfully, but these errors were encountered: