-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
An HTTP/2 204 (No Content) response containing a Content-Length header is considered invalid #140
Comments
If this issue is acknowledged, I would like to attempt to submit a fix for it. |
That looks like an unfortunate phrasing in the spec. The section is about framing, and as far as framing is concerned, having a content-length is fine even if there is no content because in HTTP/2+ the framing doesn't rely on the content-length. But that doesn't invalidate that sending a 204 response with a content-length header is wrong at the semantic level, which is where Gun rejects the response. Is this an issue with real world applications? |
Thank you for the quick response! I encountered this issue while working with an HTTP/2 API developed by another company. We have a lot of cases where the server needs to respond with 204 (No Content) responses, and their responses contain Based on your response, I understand that this is a problem with their web framework (I think they are using Javalin), so it should be fixed on the server side, right? |
If it can be fixed on the server side it should be, regardless. It doesn't help that even MDN has a 204 response example that has a content-length header... https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 If you can demonstrate that the problem exists in the wild in more than this one app then we can make an exception in Gun, behind an option, with a detailed comment explaining why. Otherwise a PR is still welcome but I'll let it sit for a while to gather feedback. |
Understood. Thank you so much! |
As the title suggests, I think the library is too strict in regards to 204 (No Content) responses that contain a
Content-Length
response header, in the context of HTTP/2.While the HTTP/1.1 spec explicitly forbid this case (RFC 7230 section 3.3.2, as well as RFC 9110 section 8.6), my understanding is that the HTTP/2 spec does not. According to RFC 9113, chapter 8.1.1, a response without content may have a content-length header field:
Versions used
gun 2.1.0
cowlib 2.13.0
erlang/otp 26
Steps to reproduce
Using an HTTP/2 server that responds with a 204 (No Content) response with or without a
Content-Length
response header (in my case https://github.com/iqltd/go-h2-yourself):Content-Length
response header, the response is handled correctlyContent-Length
response header, we get astream_error
The text was updated successfully, but these errors were encountered: