Skip to content
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

More lenient gzip decompression #2492

Merged
merged 1 commit into from Dec 21, 2016
Merged

Conversation

addaleax
Copy link
Contributor

Be explicitly lenient with gzip decompression by always requesting
zlib to flush the input data and never explicitly ending the
zlib input.

The behavioural difference is that on Node ≥ 6, which has a slightly
stricter gzip decoding process than previous Node versions, malformed
but otherwise acceptable server responses are still properly
decompressed (the most common example being a missing checksum
at the stream end).

This aligns behaviour with cURL, which always uses the Z_SYNC_FLUSH
flag for decompression.

On the downside, accidental truncation of a response is no longer
detected on the compression layer.

Ref: nodejs/node#8701 (comment)

@dege88
Copy link

dege88 commented Dec 21, 2016

I can confirm that the issue: #2482 is fixed with this PR

Be explicitly lenient with gzip decompression by always requesting
`zlib` to flush the input data and never explicitly ending the
`zlib` input.

The behavioural difference is that on Node ≥ 6, which has a slightly
stricter gzip decoding process than previous Node versions, malformed
but otherwise acceptable server responses are still properly
decompressed (the most common example being a missing checksum
at the stream end).

This aligns behaviour with cURL, which always uses the `Z_SYNC_FLUSH`
flag for decompression.

On the downside, accidental truncation of a response is no longer
detected on the compression layer.

Ref: nodejs/node#8701 (comment)
Fixes: request#2482
@addaleax
Copy link
Contributor Author

Awesome, I’ve added a Fixes: tag to the commit message.

@simov simov merged commit f009af2 into request:master Dec 21, 2016
@addaleax addaleax deleted the lenient-gzip branch December 21, 2016 23:46
VisualFox added a commit to VisualFox/iframely that referenced this pull request Jan 24, 2017
This fix an issue with zlib: unexpected end of file with node v7.2.1 - Follow the PR: More lenient gzip decompression #2492 request/request#2492 -
TimothyGu pushed a commit to node-fetch/node-fetch that referenced this pull request Feb 27, 2017
fatboy0112 added a commit to fatboy0112/node-fetch that referenced this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants