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
Incorrect order of response body decompression when there are multiple content encodings in undici.fetch (?) #2158
Comments
It seems like the codings are applied in the wrong order. PR welcome. |
The specification states that the sender must set the header properly. If the body is being decompressed incorrectly, this doesn't seem to be an issue with undici? |
As I'm undersanding it, the sender is sending the header correctly, undici is not decompressing correctly. It's applying the decoders in the reverse order. |
that doesn't seem to match the code though Lines 2007 to 2036 in 2032e89
|
@KhafraDev As I've pointed in the issue description
So I believe the loop from your comment should iterate over |
would you like to send in a PR? |
Sure, will send |
nodejs#2158) (nodejs#2159) Co-authored-by: rychkog-ma <georgii.ry@moonactive.com>
Bug Description
I might misunderstood the spec, but
According to specification the
Content-Encoding
might have multiple encodings:
And based on the implementation it is not the case:
https://github.com/nodejs/undici/blob/main/lib/fetch/index.js#L2007
Reproducible By
Run following server
Try to fetch the data:
Expected Behavior
When there is a payload with following
Content-Encoding: deflate, gzip
we need to decode it withgzip
first and then withdeflate
The code above crashes right now, but should return properly decoded text.
Logs & Screenshots
N/A
Environment
Ubuntu 22.04 LTS, Node v16.20.0
Additional context
N/A
The text was updated successfully, but these errors were encountered: