Skip to content

Instantly share code, notes, and snippets.

@sasikanth
Created September 28, 2015 06:45
Show Gist options
  • Select an option

  • Save sasikanth/977e6af7744173b7111b to your computer and use it in GitHub Desktop.

Select an option

Save sasikanth/977e6af7744173b7111b to your computer and use it in GitHub Desktop.
Frisby test : How to decompress a raw Buffer with Gunzip.( Asynchronously )
//gunzip Sample
var frisby=require('frisby');
var zlib = require('zlib');
var tc02 = frisby.create('Gzip Test');
tc02.get('http://httpbin.org/gzip', { encoding: null })
.after(function(error, response, body){
if (!error && response.statusCode == 200) {
var encoding = response.headers['content-encoding']
if (encoding && encoding.indexOf('gzip') > -1) {
zlib.gunzip(body, function(err, dezipped) {
var json_string = dezipped.toString('utf-8');
var json = JSON.parse(json_string);
console.log(json);
});
} else {
console.log("Response encoding is not gzip");
}
}
})
.toss();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment