Skip to content

Instantly share code, notes, and snippets.

@katanacrimson
Last active December 11, 2015 16:49
Show Gist options
  • Save katanacrimson/4630354 to your computer and use it in GitHub Desktop.
Save katanacrimson/4630354 to your computer and use it in GitHub Desktop.
var zlib = require('zlib')
zlib.gzip(Buffer('test'), function(err, res) {
console.dir(res)
var resString = res.toString()
var resBuffer = Buffer(resString, 'binary')
console.dir(resBuffer)
zlib.gunzip(resBuffer, function(err, text) {
if(err) throw err
console.log(text.toString())
})
})
/*
$ node 4198.js
<Buffer 1f 8b 08 00 00 00 00 00 00 03 2b 49 2d 2e 01 00 0c 7e 7f d8 04 00 00 00>
<Buffer 1f fd 08 00 00 00 00 00 00 03 2b 49 2d 2e 01 00 0c 7e 7f fd 04 00 00 00>
Error: incorrect header check
at Zlib._binding.onerror (zlib.js:283:17)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment