-
Notifications
You must be signed in to change notification settings - Fork 595
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #4213: Content-Length when entity is unallowed #4214
fix #4213: Content-Length when entity is unallowed #4214
Conversation
At least one commit author (antoine.bursaux@kelkoogroup.com) is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user |
dab29c9
to
471e6ca
Compare
Trying to verify this is the right thing I found RFC 9110 (which obsoletes 7231) saying: https://httpwg.org/specs/rfc9110.html#field.content-length
And
So I wonder if a fix can really be this easy, I think it needs to be specifically/selectively emitted based on the status code and request method. It also explicitly contradicts emitting it for 204. |
Thanks @johanandren for pointing that out. You are right, it will require some case-by-case handling, I will proceed with the changes. Also I inadvertently added the header to 1xx responses ( |
Wdyt about the explicit MUST NOT emit content length for 204, that seems like it contradicts what the clients expect if it is as you describe in the issue? |
I specifically encountered the issue with a 205 code. It was mentioned in the linked issue, but I oversimplified in this pull request. Testing with It turns out to be very specific to the 205 code... The previous condition on There are also cases with HEAD and CONNECT methods that I did not encounter, I do not even know to what degree they would realistically cause issues to clients (a response body seems very unlikely for these methods), but might as well align them with the RFC while working on it. |
471e6ca
to
ab3bcab
Compare
Not entirely related, but you made me think @johanandren ... And I stumbled upon these tests with HEAD requests containing bodies (
|
akka-http-core/src/main/scala/akka/http/impl/engine/rendering/HttpResponseRendererFactory.scala
Outdated
Show resolved
Hide resolved
I think we can leave HEAD returning bodies alone for now, as you say it is against spec, but in case anyone is relying on doing that already. |
70a2675
to
cf2e29c
Compare
akka-http-core/src/main/scala/akka/http/scaladsl/model/HttpMethod.scala
Outdated
Show resolved
Hide resolved
14e1a82
to
16bd97c
Compare
Some related test failures, and some I'm not entirely sure about, to look into. Also, failures from MiMa which is our binary incompatibility detection, I think all of them can now safely be filtered as described here: https://github.com/akka/akka-http/blob/main/CONTRIBUTING.md#binary-compatibility |
16bd97c
to
7672d21
Compare
akka-http-core/src/main/scala/akka/http/scaladsl/model/HttpMethod.scala
Outdated
Show resolved
Hide resolved
akka-http-core/src/test/scala/akka/http/impl/engine/client/HostConnectionPoolSpec.scala
Show resolved
Hide resolved
7672d21
to
616e374
Compare
Tests were good with previous run, this one should take care of binary incompatibilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Adds
Content-Length: 0
header on responses that do not allow a response body (204, 205 and 304).I did not add a specific test, as there was already a test for rendering a 304 response - I simply made that test more correct 馃檪
Fixes #4213