Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | const OriginalHttpsAgent = require('https').Agent;
|
---|
| 4 | const HttpAgent = require('./agent');
|
---|
| 5 | const {
|
---|
| 6 | INIT_SOCKET,
|
---|
| 7 | CREATE_HTTPS_CONNECTION,
|
---|
| 8 | } = require('./constants');
|
---|
| 9 |
|
---|
| 10 | class HttpsAgent extends HttpAgent {
|
---|
| 11 | constructor(options) {
|
---|
| 12 | super(options);
|
---|
| 13 |
|
---|
| 14 | this.defaultPort = 443;
|
---|
| 15 | this.protocol = 'https:';
|
---|
| 16 | this.maxCachedSessions = this.options.maxCachedSessions;
|
---|
| 17 | /* istanbul ignore next */
|
---|
| 18 | if (this.maxCachedSessions === undefined) {
|
---|
| 19 | this.maxCachedSessions = 100;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | this._sessionCache = {
|
---|
| 23 | map: {},
|
---|
| 24 | list: [],
|
---|
| 25 | };
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | createConnection(options) {
|
---|
| 29 | const socket = this[CREATE_HTTPS_CONNECTION](options);
|
---|
| 30 | this[INIT_SOCKET](socket, options);
|
---|
| 31 | return socket;
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | // https://github.com/nodejs/node/blob/master/lib/https.js#L89
|
---|
| 36 | HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection;
|
---|
| 37 |
|
---|
| 38 | [
|
---|
| 39 | 'getName',
|
---|
| 40 | '_getSession',
|
---|
| 41 | '_cacheSession',
|
---|
| 42 | // https://github.com/nodejs/node/pull/4982
|
---|
| 43 | '_evictSession',
|
---|
| 44 | ].forEach(function(method) {
|
---|
| 45 | /* istanbul ignore next */
|
---|
| 46 | if (typeof OriginalHttpsAgent.prototype[method] === 'function') {
|
---|
| 47 | HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method];
|
---|
| 48 | }
|
---|
| 49 | });
|
---|
| 50 |
|
---|
| 51 | module.exports = HttpsAgent;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.