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