Skip to content

Instantly share code, notes, and snippets.

@sasikanth
Created September 28, 2015 06:43
Show Gist options
  • Save sasikanth/1c60263a49d663835266 to your computer and use it in GitHub Desktop.
Save sasikanth/1c60263a49d663835266 to your computer and use it in GitHub Desktop.
Frisby test : Decompress a raw Buffer with Gunzip.(Synchronously)
//gunZipSync sample
var frisby=require('frisby');
var zlib = require('zlib');
var tc01 = frisby.create('Gzip Test');
tc01.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) {
console.log(zlib.gunzipSync(body).toString('utf-8'));
} 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