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

Question: inflateRaw or inflate? #24

Closed
heroboy opened this issue Mar 19, 2020 · 2 comments
Closed

Question: inflateRaw or inflate? #24

heroboy opened this issue Mar 19, 2020 · 2 comments

Comments

@heroboy
Copy link

heroboy commented Mar 19, 2020

I'm using npm package 'got' to make request to some url. And get 'Error: incorrect header check'.
Becuase 'got' use this package to decompress the body, so I ask question here.
The uncompressed response body is
<Buffer ab 56 4a 2d 2a 4a ce 4f 49 55 b2 32 d0 01 b1 73 8b d3 95 ac 94 f2 b3 95 6a 01>
response header: 'content-encoding': 'deflate'.
I find that I can use inflateRawSync to decompress the body. But has the same error when decompress it using inflateSync.
So what I should use? or it is the server's error.

@heroboy
Copy link
Author

heroboy commented Mar 19, 2020

Because you are using createUnzip to decompress the deflate.
I make some test:
first:

const http = require('http');
let server = http.createServer((req, res) =>
{
	res.writeHead(200, { 'Content-Type': 'text/plain', 'content-encoding': 'deflate' });
        //whether using deflateRaw or deflate, the browser can decompress it successfully.
	res.end(zlib.deflateRawSync('abc'));
})

and

console.log(zlib.unzipSync(zlib.deflateSync('abc')))// this is ok.
console.log(zlib.unzipSync(zlib.deflateRawSync('abc')))// this will throw 'Error: incorrect header check'

So using createUnzip can't handle the data that the browser can handle.

@sindresorhus
Copy link
Owner

Closing for the same reason as sindresorhus/got#1124 (comment).

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

No branches or pull requests

2 participants