Created
March 21, 2016 15:58
-
-
Save tr4n2uil/55ba1041130117965700 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'); | |
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