Last active
December 23, 2015 20:09
-
-
Save queckezz/6687167 to your computer and use it in GitHub Desktop.
Simple Buffer collector example
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 http = require('http'); | |
var url = process.argv[2]; | |
http.get(url, function (res) { | |
//res.setEncoding('utf-8'); | |
var bufs; | |
res.on('data', function (buf) { | |
bufs = (!bufs) | |
? bufs = buf | |
: bufs += buf; | |
}); | |
res.on('end', function () { | |
var data = bufs.toString(); | |
console.log(data.length); | |
console.log(data); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment