Skip to content

Instantly share code, notes, and snippets.

@tr4n2uil
Created March 21, 2016 15:58
Show Gist options
  • Save tr4n2uil/55ba1041130117965700 to your computer and use it in GitHub Desktop.
Save tr4n2uil/55ba1041130117965700 to your computer and use it in GitHub Desktop.
var http = require('http');
var agent;
if(process.version.substring(0,5) == 'v0.10'){
var AgentKeepAlive = require('agentkeepalive');
agent = new AgentKeepAlive({
keepAliveTimeout: 30*1000
});
}
else {
var agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 30*1000
});
}
var httpRequest = http.request;
http.request = function(options, callback){
options["agent"] = agent;
return httpRequest(options, callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment