https_agent.js 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Https Agent base on custom http agent
  3. */
  4. 'use strict';
  5. const https = require('https');
  6. const HttpAgent = require('./agent');
  7. const OriginalHttpsAgent = https.Agent;
  8. class HttpsAgent extends HttpAgent {
  9. constructor(options) {
  10. super(options);
  11. this.defaultPort = 443;
  12. this.protocol = 'https:';
  13. this.maxCachedSessions = this.options.maxCachedSessions;
  14. if (this.maxCachedSessions === undefined) {
  15. this.maxCachedSessions = 100;
  16. }
  17. this._sessionCache = {
  18. map: {},
  19. list: [],
  20. };
  21. }
  22. }
  23. [
  24. 'createConnection',
  25. 'getName',
  26. '_getSession',
  27. '_cacheSession',
  28. // https://github.com/nodejs/node/pull/4982
  29. '_evictSession',
  30. ].forEach(function(method) {
  31. if (typeof OriginalHttpsAgent.prototype[method] === 'function') {
  32. HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method];
  33. }
  34. });
  35. module.exports = HttpsAgent;