Created
May 21, 2013 15:53
-
-
Save dpogorzelski/5620910 to your computer and use it in GitHub Desktop.
Read http request's body which has a gzip content encoding (node.js);
This file contains 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
var https = require('https'); | |
var gunzip = require('zlib').createGunzip(); | |
var options = { | |
host: 'api.stackexchange.com', | |
path: '/2.1/info?site=stackoverflow' | |
}; | |
https.get(options, function(res) { | |
var body = ''; | |
res.pipe(gunzip); | |
gunzip.on('data', function (data) { | |
body += data; | |
}); | |
gunzip.on('end', function() { | |
console.log(JSON.parse(body)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment