-
Notifications
You must be signed in to change notification settings - Fork 177
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: remove encoding from response #1076
Conversation
Same thing, good cleanup 👍 |
It breaks two unit tests though, taking a look. |
While this part definitively requires cleanup, this change outputs responses with no transfer-encoding nor content-size headers, which is a problem (the only way to end the body is then to close the connection). I think we should clean it up even further: I think there is no point in letting the user force the encoding, as she could for instance specify an incorrect content-length and ruin the protocol. This should IMO be an implementation detail entirely handled by cohttp. The only encoding feature that could arguably exist is forcing chunked encoding despite knowing the body length, which seems a bit wasteful but not incorrect per se. Thus I would suggest we
There is still the issue that the user can specify headers manually and thus forcefully insert erroneous headers, but I blame HTTP 1 for this, as it mixes up transport and application layers in the headers. We could either manually fix these headers, or decline any responsibility if they are set manually. |
Happy working on this if we agree on the desired result. It would definitely be a good thing to clean this up before 6.0. |
Here's already a small fix that restore the previous behavior and thus fixes the test suite : https://github.com/mefyl/ocaml-cohttp/tree/fix/remove-encoding-from-response . The main difference is that encoding is set to Chunked by default. I changed one test expectation because the server now return I'm still a bit uneasy with the way encoding is determined, but with this on top I think this MR is already a good step forward. |
Thanks for the response. I think there's two separate concerns:
My PR attempts to follow 1, while your commit helps out with 2. Looking at your commit, it seems like a good approach to me. Your proposal to make it easier to construct correct responses with bodies seems good as well. However, I think we should still allow the users to construct incorrect requests/responses in some lower level layer. In the real world, there's plenty of situations where one has to deal with non spec compliant clients and servers. |
Co-authored-by: mefyl <[email protected]> <!-- ps-id: 5a6bf1dd-0b7f-4321-a861-20982306c8e4 -->
6fe3817
to
64c5711
Compare
I've included your commit but adjusted it to not to overwrite user set headers. |
I agree, and I think this should be split across libraries:
|
one more @mefyl