Created
March 31, 2015 15:11
-
-
Save crash2burn/76c840a05416dd394179 to your computer and use it in GitHub Desktop.
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') | |
function Wat() { | |
} | |
Wat.prototype.get = function(cb) { | |
var options = { | |
host: "http://whatevaljksdskajd.com", | |
port: "80", | |
path: "", | |
headers: {'Content-Type': 'application/json'}, | |
method: 'GET', | |
followAllRedirects: true | |
}; | |
var callback = function(response) { | |
response.setEncoding('utf-8'); | |
var str = '' | |
response.on('data', function (chunk) { | |
str += chunk; | |
}); | |
response.on('end', function () { | |
cb(null, str) | |
}); | |
response.on('error', function (e) { | |
cb(e); | |
}); | |
} | |
var req = http.request(options, callback); | |
req.on('error', function (e) { | |
cb(e); | |
}); | |
req.end(); | |
} | |
w = new Wat(); | |
setInterval(function() { | |
w.get(function Werd(res) { | |
//console.log(res) | |
}) | |
}, 500) | |
setInterval(function () { | |
console.log(process.memoryUsage().rss) | |
}, 2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment