-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
fix(res.send): add Content-Length header only if Transfer-Encoding is not present #4893
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
base: master
Are you sure you want to change the base?
Conversation
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.
Please add a test that fails without this change and passes with it so the fix does not regress.
Hey @dougwilson , |
Hey, sorry I was just trying to get the new release out. It looks like you still need to add a test for the change to res.redirect, as that was changed too. I also took a look in the Node.js source and they also have logic for content-length vs transfer-encoding, but node.js only does stuff if transfer-encoding contains chunked while here is it any value (even a single space character). Is that intentional? Should we follow what the node.js logic is? It may help if the underlying issue you ran in to for this change was disclosed. |
Hey @dougwilson, About the issue we are running in. |
Ah, ok. Can you add tests for other values of transfer-encoding besides chunked as well, then? We want to make sure that res.send will work with other values too. As for mocking exact replicas of other apis, you typically want to use the lower-level apis for that like res.write and res.end instead of res.send. |
Hey @dougwilson, Regards, |
Hey! It's no problem at all :) Thanks for adding to the tests. But I think there is an issue with them: though you added other values, it does not seem like res.send is actually honoring them. For example, if you have Transfer-Encoding: gzip set, can the test show that res.send will actually send it as gzip? Example I would expect |
Hey @dougwilson! Can we actually test that our response transforms to gzip? I think its very low level and I'm not sure that nodejs can transform our response to gzip/compress/deflate. Because I did not find any mentions about Of course tools like I have a suggestion to check our response for having a Please, correct me guys if I’m wrong. Thank you! |
eb10dba
to
340be0f
Compare
You can check the spec for transfer-encoding at https://datatracker.ietf.org/doc/html/rfc9112#name-transfer-encoding The very first example shows how it can invlue gzip. |
@dougwilson Do you expect that response has corresponding |
Intent
Content-Length
andTransfer-Encoding
can't be present in the response headers together,Content-Length
should be added only if there is noTransfer-Encoding
header.