Skip to content

Instantly share code, notes, and snippets.

@bingeboy
Created July 1, 2013 02:38
Show Gist options
  • Save bingeboy/5898024 to your computer and use it in GitHub Desktop.
Save bingeboy/5898024 to your computer and use it in GitHub Desktop.
Loop for GET requests.
var http = require('http');
var pool = require('generic-pool').Pool({
name : 'http_request',
create : function(callback) {
var c = http.createClient(80, '127.0.0.1');
callback(null, c);
},
destroy : function(client) { },
max : 10,
idleTimeoutMillis : 300,
log : false
});
for(var i = 0; i < 200000; i++) {
pool.acquire(function(err, client) {
var request = client.request("GET", '/');
request.end();
request.on('response', function(response) {
console.log(response.statusCode);
pool.release(client);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment