export function closeConnections() { agent && agent.destroy(); agent = null; }
/** * Creates a new HttpsOcspAgent. * * @param {Object} options * * @returns {HttpsOcspAgent} * @constructor */ function HttpsOcspAgent(options) { return HttpsAgent.apply(this, arguments); }
router.get('/http_stats', (req, res) => { res.json({ http: { sockets: socketStats(http.globalAgent.sockets), freeSockets: socketStats(http.globalAgent.freeSockets), }, https: { sockets: socketStats(https.globalAgent.sockets), freeSockets: socketStats(https.globalAgent.freeSockets), }, }); });
const setupHTTPClient = () => { if (httpConfig.useCertFile) { if (httpConfig.certFile !== undefined) { https.globalAgent.options.ca = [fs.readFileSync(httpConfig.certFile)]; log.info('Loaded cert file:', httpConfig.certFile); } } http.globalAgent.keepAlive = httpConfig.keepAlive; https.globalAgent.keepAlive = httpConfig.keepAlive; }
_.forEach(userDefinedCAStores, store => { https.globalAgent.options.ca.push(Fs.readFileSync(store)); });
https.globalAgent.options.ca = cas;
https.globalAgent.options.ca = []; httpConfig.keepAlive = false; httpConfig.useCertFile = false; expect(https.globalAgent.options.ca).to.have.lengthOf(0); setupHTTPClient(); expect(https.globalAgent.options.ca).to.have.lengthOf(1); }); expect(https.globalAgent.options.ca).to.have.lengthOf(0); setupHTTPClient(); expect(https.globalAgent.options.ca).to.have.lengthOf(0); }); expect(https.globalAgent.options.ca).to.have.lengthOf(0); setupHTTPClient(); expect(https.globalAgent.options.ca).to.have.lengthOf(0); }); expect(https.globalAgent.options.ca).to.have.lengthOf(0); }); setupHTTPClient(); expect(http.globalAgent.keepAlive).to.be.false; expect(https.globalAgent.keepAlive).to.be.false; }); setupHTTPClient(); expect(http.globalAgent.keepAlive).to.be.true;
var createConnection = agent.createConnection;
/** * HttpsMockAgentOcspUnkwown returns unknown error * @param options * @constructor */ function HttpsMockAgentOcspUnkwown(options) { return HttpsAgent.apply(this, arguments); }
/** * HttpsMockAgentOcspRevoked - return revoked error * @param options * @constructor */ function HttpsMockAgentOcspRevoked(options) { return HttpsAgent.apply(this, arguments); }
/** * HttpsMockAgentOcspInvalid returns invalid validity OCSP error * @param options * @constructor */ function HttpsMockAgentOcspInvalid(options) { return HttpsAgent.apply(this, arguments); }