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
204 No Content should throw error when body is sent instead of parsing it #196
Comments
Hi @neonichu, thanks for the report and for opening this issue and for the feedback! I'm excited you're using Dredd! I'm sorry, but I'm afraid this is not a bug. My intention here was when you declare body should be a parseable JSON in the My opinion is that it makes no sense to send any See [RFC2616, §7.2.1]http://tools.ietf.org/search/rfc2616#section-7.2.1()
|
Dredd is awesome, thanks a lot for making it 👍 I guess this is an edge case :) Section "10.2.5 204 No Content" of the same RFC states:
Feel free to close this, though, if this works as you intended. |
Thanks for pointing this out. Do you think that Dredd should not parse body on |
I think so, as "MUST NOT" is defined as "absolute prohibition" in RFCs, sending a body with a |
Well, I'll rename this issue if you don't mind :) Thank you! |
I ran into a similar issue, because I am using class RemoveContentType
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
bbody = body.body
#Remove Content-Type if there is no body
headers.delete('Content-Type') if bbody.length == 0
return [status, headers, body]
end
end And then called |
@milch Thanks! 🍬 |
I am hitting this issue as well. Returning from an OPTIONS request is failing in Dredd as it attempts to parse the JSON when there is no content. I would argue that there doesn't have to be a Body if there is a Content-Type header, but there must be a Content-type header if there is a body. Certainly the RFC indicates that in the event of a 204 then the Body should be ignored. |
Just letting know I proposed a solution for this issue here #556 with a temporary workaround solution with use of hooks. |
Hi folks, please check out a new proposed behavior and let me know if that would work for you: #556 (comment) |
I believe this is already addressed by v4.7.1 and further, I just forgot to close this one. Thanks everyone involved and I'm sorry it took so long to fix this. |
Change how the package works 🚚
If a 204 HTTP response contains a content-type header, dredd tries to parse the empty response and fails, thus breaking the test. As 204 response must not have a body, this doesn't seem like a good behaviour.
Blueprint:
Dredd output:
The text was updated successfully, but these errors were encountered: