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 header check when deal with deflate content encoding #2197

Open
goorockey opened this Issue May 3, 2016 · 13 comments

Comments

Projects
None yet
@goorockey

goorockey commented May 3, 2016

var rq = require('request');
rq.get('https://web.wechat.com', {gzip: true});

Error: incorrect header check
    at Zlib._handle.onerror (zlib.js:370:17)

While the response from https://web.wechat.com is in deflate format, it show this error.
According to PR #2172, request library support deflate content encoding.

After I change responseContent = zlib.createInflate() to responseContent = zlib.createInflateRaw() in request.js, it work fine.

@simov

This comment has been minimized.

Member

simov commented May 3, 2016

That's interesting, it looks like our implementation is too optimistic. The only possible solution that I can think of is to peek into the stream and check if the zlib headers are present, then switch to either createInflate or createInflateRaw.

@windbender

This comment has been minimized.

windbender commented Jun 17, 2016

FWIW I found this precise error when trying to use tar.gz to decompress a x.tar.gz file created on an OS X machine

octogon:tmp lumigrow$ targz e ver1.tar.gz .
/usr/local/lib/node_modules/tar.gz/bin/targz:18
        throw err;
        ^
Error: incorrect header check
    at Zlib._handle.onerror (zlib.js:370:17)

The file is attached

ver1.tar.gz

czardoz pushed a commit to czardoz/request that referenced this issue Aug 16, 2016

czardoz pushed a commit to czardoz/request that referenced this issue Aug 17, 2016

@adampash

This comment has been minimized.

adampash commented Nov 9, 2016

Fwiw, I was running into the same error, and the @czardoz branch fixed it for me. (Thanks @czardoz!)

@umutm

This comment has been minimized.

umutm commented Jan 10, 2017

We also experience the same issue for some websites. Is there a planned official fix for that?

@gotojmp

This comment has been minimized.

gotojmp commented Feb 25, 2017

waiting for fix.

@mfrye

This comment has been minimized.

mfrye commented Mar 2, 2017

I came across this on something unrelated, but @czardoz has a legit fix. It seems like that code should be apart of zlib right? To auto detect instances like that.

@thesadabc

This comment has been minimized.

thesadabc commented Mar 11, 2017

waiting for fix

2 similar comments
@ali-habibzadeh

This comment has been minimized.

ali-habibzadeh commented Apr 7, 2017

waiting for fix

@mweathers

This comment has been minimized.

mweathers commented Sep 15, 2017

waiting for fix

@rogierslag

This comment has been minimized.

rogierslag commented Sep 18, 2017

@goddkiller

This comment has been minimized.

goddkiller commented Nov 15, 2017

another method to avoid this problem is to set Accept-Encoding: gzip.
tell the server that you only use gzip.

@jiangts

This comment has been minimized.

jiangts commented Jan 25, 2018

Why isn't the @czardoz branch getting submitted as a PR for merging?

@czardoz

This comment has been minimized.

Contributor

czardoz commented Feb 9, 2018

@jiangts Thanks for opening up a PR. I didn't get around to pushing my changes upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment