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

incorrect header check when deal with deflate content encoding #2197

Open
goorockey opened this issue May 3, 2016 · 14 comments
Open

incorrect header check when deal with deflate content encoding #2197

goorockey opened this issue May 3, 2016 · 14 comments

Comments

@goorockey
Copy link

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
Copy link
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
Copy link

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
Copy link

adampash commented Nov 9, 2016

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

@umutm
Copy link

umutm commented Jan 10, 2017

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

@gotojmp
Copy link

gotojmp commented Feb 25, 2017

waiting for fix.

@mfrye
Copy link

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
Copy link

waiting for fix

2 similar comments
@ali-habibzadeh
Copy link

waiting for fix

@mweathers
Copy link

waiting for fix

@rogierslag
Copy link

I'd also love a fix for this. http://www.mars.com/uk/en/careers/graduates-students/our-programmes/european-finance-development-programme is encountering the same problem

@goddkiller
Copy link

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

@jiangts
Copy link

jiangts commented Jan 25, 2018

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

@czardoz
Copy link
Contributor

czardoz commented Feb 9, 2018

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

@dreamalligator
Copy link

looks like this issue is still happening? I think via my jsdom dependency that requires request.

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

No branches or pull requests