Created
September 28, 2015 06:43
-
-
Save sasikanth/1c60263a49d663835266 to your computer and use it in GitHub Desktop.
Frisby test : Decompress a raw Buffer with Gunzip.(Synchronously)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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