describe("#NodeHttpStack", function () { it("should allow to pass options to Node's requests", async function () { const customAgent = new https.Agent(); const stack = (new tus.HttpStack({ agent: customAgent })); const req = stack.createRequest("GET", "https://master.tus.io/"); await req.send(); expect(req.getUnderlyingObject().agent).toBe(customAgent); expect(req.getUnderlyingObject().agent).not.toBe(https.globalAgent); }); });
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), }, }); });
constructor(options){ super(); this.httpsAgent = https.globalAgent; this.httpAgent = http.globalAgent; this.init(options); }
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)); });
constructor(){ super(...arguments); this.Agent = https.Agent; this.globalAgent = https.globalAgent; this.enforceProtocol = 'https:'; }
if (code === '200') { if (use_secure === 'disable') { http.globalAgent.maxSockets = 1000000; http.createServer(app).listen({port: usecsebaseport, agent: false}, function () { console.log('mobius server (' + ip.address() + ') running at ' + usecsebaseport + ' port'); ca: fs.readFileSync('ca-crt.pem') }; https.globalAgent.maxSockets = 1000000; https.createServer(options, app).listen({port: usecsebaseport, agent: false}, function () { console.log('mobius server (' + ip.address() + ') running at ' + usecsebaseport + ' port');
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); }); expect(http.globalAgent.keepAlive).to.be.false; expect(https.globalAgent.keepAlive).to.be.false; }); httpConfig.keepAlive = true; setupHTTPClient(); expect(http.globalAgent.keepAlive).to.be.true;
http.globalAgent.maxSockets = 1000000; http.createServer(app).listen({port: usecsebaseport, agent: false}, function () { console.log('mobius server (' + ip.address() + ') running at ' + usecsebaseport + ' port'); ca: fs.readFileSync('ca-crt.pem') }; https.globalAgent.maxSockets = 1000000; https.createServer(options, app).listen({port: usecsebaseport, agent: false}, function () { console.log('mobius server (' + ip.address() + ') running at ' + usecsebaseport + ' port');