-
Notifications
You must be signed in to change notification settings - Fork 787
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
No Content responses can have content-length but no body #7249
Comments
Thanks!
Maybe around here? Not sure what's the best way to handle this. http4s/ember-core/shared/src/main/scala/org/http4s/ember/core/Encoder.scala Lines 65 to 70 in ce7de6b
|
Indeed 😀 I did find that chunk of code but wasn't sure I'd followed the correct path as it seems to always include the body, I can't figure out where that gets dropped. From the bottom of that function: http4s/ember-core/shared/src/main/scala/org/http4s/ember/core/Encoder.scala Lines 79 to 86 in ce7de6b
Naively it seems like wrapping http4s/ember-core/shared/src/main/scala/org/http4s/ember/core/Encoder.scala Lines 55 to 62 in ce7de6b
|
I'm inclined close this issue as I don't think it behaves like I originally thought. This can be shown by using netcat to craft a http request: e.g. Ultimately I believe it's wrong by the HTTP spec to return a body in this case, and some clients will handle it and some wont because it's not well defined what they should do in this situation. But whether http4s should override the explicitly stated intentions of the user (this isn't possible with the standard DSL) to enforce the correct behaviour is a bigger question |
A custom No Content response, that incorrectly includes a body and an explicit
Content-Length
header, results in an inconsistent http response.Ember server seems to drop the body, but leaves the
Content-Length
header. This can cause some clients to timeout waiting for content that never arrives. Since ember already ignores the body it seems like it wouldn't be a stretch to also ignore the givenContent-Length
header as well (conceptually anyway 😀 , I've no idea about the code change required to make this happen, if someone can point me in the right direction I'm happy to work on it and raise a PR).Depending on how a No Content response is constructed, and how it is exercised, the response can vary.
I've created a reproduction of this here: https://gist.github.com/mikeshepherd/10ab7e5c2cfb933c587f3e01bf1c06a6
Edit: This was discovered while using smithy4s, which generates http4s code, making it hard to just use the standard
NoContent
response. See disneystreaming/smithy4s#1169The text was updated successfully, but these errors were encountered: