-
Notifications
You must be signed in to change notification settings - Fork 40
fix: Always set Content-Length field in non-100/204 responses #48
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
fix: Always set Content-Length field in non-100/204 responses #48
Conversation
2905bb5
to
1f9a265
Compare
1f9a265
to
5293dea
Compare
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.
Why is it important to distinguish between no content and empty content? could we not just always return Content-Length: 0
?
5293dea
to
c295b53
Compare
There are many cases where the server should not contain 'Content-Length' field in response. Please see RFC 9110.
|
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.
I think this would also benefit from an integration test in test_mmds.py
? What do you think?
@pb8o Yes, we can have it on the firecracker side. I'll implement it on firecracker repo (not on micro-http repo). |
dc751a0
to
95c0794
Compare
95c0794
to
d42feed
Compare
The client may wait for the server to close the connection or for timeout to occur in some cases. This commit changes it to always set Content-Length field in non-100/204 responses regardless of whether the body is empty. Although it doesn't cover all the patterns where the response must not set it, users can remove it by calling `set_content_length(None)`. Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
d42feed
to
0164349
Compare
When querying a MMDS path that has an empty content, the response didn't contain 'Content-Length' field, resulting in the client waiting for the connection closed by the server or timeout. To fix this issue, micro-http made a change to have the field when the response status code is not 1XX or 204. This commit updates Cargo.lock file to consume this change and also adds an integration test to ensure that it doesn't timeout for an empty MMDS path. The micro-http's change is made on firecracker-microvm/micro-http#48. Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
When querying a MMDS path that has an empty content, the response didn't contain 'Content-Length' field, resulting in the client waiting for the connection closed by the server or timeout. To fix this issue, micro-http made a change to have the field when the response status code is not 1XX or 204. This commit updates Cargo.lock file to consume this change and also adds an integration test to ensure that it doesn't timeout for an empty MMDS path. The micro-http's change was made on firecracker-microvm/micro-http#48. Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
When querying a MMDS path that has an empty content, the response didn't contain 'Content-Length' field, resulting in the client waiting for the connection closed by the server or timeout. To fix this issue, micro-http made a change to have the field when the response status code is not 1XX or 204. This commit updates Cargo.lock file to consume this change and also adds an integration test to ensure that it doesn't timeout for an empty MMDS path. The micro-http's change was made on firecracker-microvm/micro-http#48. Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
When querying a MMDS path that has an empty content, the response didn't contain 'Content-Length' field, resulting in the client waiting for the connection closed by the server or timeout. To fix this issue, micro-http made a change to have the field when the response status code is not 1XX or 204. This commit updates Cargo.lock file to consume this change and also adds an integration test to ensure that it doesn't timeout for an empty MMDS path. The micro-http's change was made on firecracker-microvm/micro-http#48. Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Reason for This PR
Without having 'Content-Length: 0' for an empty content, a client may wait for the server to close the connection or for a timeout to occur like follows:
With this change, the client can close the connection soon after it gets the response.
Description of Changes
set_content_length(None)
if needed.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).[ ] Any required documentation changes (code and docs) are included in this PR.[ ] Any newly addedunsafe
code is properly documented.CHANGELOG.md
.