How to use the http-proxy._getAgent function in http-proxy

To help you get started, we’ve selected a few http-proxy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bbytes / proxy-etc / proxy / revproxy.js View on Github external
exports.init = function() {
    if (config.httpKeepAlive !== true) {
        // Disable the http Agent of the http-proxy library so we force
        // the proxy to close the connection after each request to the backend
        httpProxy._getAgent = function () {
            return false;
        };
    }
    httpProxy.setMaxSockets(config.maxSockets);
	
    function readRoutesJson(){
        fs.readFile("./config/routes.json", function (err, data) {
            if (err) {
          	  console.error("Error reading file");
            }
            routesJson = JSON.parse(data);
         });
    }
    readRoutesJson();
    fs.watchFile("./config/routes.json", function () {
    	readRoutesJson();