(type, options, socket)
| 1291 | // will be sent to the socket. |
| 1292 | class Http2Session extends EventEmitter { |
| 1293 | constructor(type, options, socket) { |
| 1294 | super(); |
| 1295 | |
| 1296 | // No validation is performed on the input parameters because this |
| 1297 | // constructor is not exported directly for users. |
| 1298 | |
| 1299 | // If the session property already exists on the socket, |
| 1300 | // then it has already been bound to an Http2Session instance |
| 1301 | // and cannot be attached again. |
| 1302 | if (socket[kBoundSession] !== undefined) |
| 1303 | throw new ERR_HTTP2_SOCKET_BOUND(); |
| 1304 | |
| 1305 | socket[kBoundSession] = this; |
| 1306 | |
| 1307 | if (!socket._handle || !socket._handle.isStreamBase) { |
| 1308 | socket = new JSStreamSocket(socket); |
| 1309 | } |
| 1310 | socket.on('error', socketOnError); |
| 1311 | socket.on('close', socketOnClose); |
| 1312 | |
| 1313 | this[kState] = { |
| 1314 | destroyCode: NGHTTP2_NO_ERROR, |
| 1315 | flags: SESSION_FLAGS_PENDING, |
| 1316 | goawayCode: null, |
| 1317 | goawayLastStreamID: null, |
| 1318 | streams: new SafeMap(), |
| 1319 | pendingStreams: new SafeSet(), |
| 1320 | pendingAck: 0, |
| 1321 | shutdownWritableCalled: false, |
| 1322 | writeQueueSize: 0, |
| 1323 | originSet: undefined, |
| 1324 | }; |
| 1325 | |
| 1326 | this[kEncrypted] = undefined; |
| 1327 | this[kAlpnProtocol] = undefined; |
| 1328 | this[kType] = type; |
| 1329 | this[kProxySocket] = null; |
| 1330 | this[kSocket] = socket; |
| 1331 | this[kTimeout] = null; |
| 1332 | this[kHandle] = undefined; |
| 1333 | this[kStrictSingleValueFields] = |
| 1334 | options.strictSingleValueFields; |
| 1335 | |
| 1336 | // Do not use nagle's algorithm |
| 1337 | if (typeof socket.setNoDelay === 'function') |
| 1338 | socket.setNoDelay(); |
| 1339 | |
| 1340 | // Disable TLS renegotiation on the socket |
| 1341 | if (typeof socket.disableRenegotiation === 'function') |
| 1342 | socket.disableRenegotiation(); |
| 1343 | |
| 1344 | const setupFn = setupHandle.bind(this, socket, type, options); |
| 1345 | if (socket.connecting || socket.secureConnecting) { |
| 1346 | const connectEvent = |
| 1347 | socket instanceof tls.TLSSocket ? 'secureConnect' : 'connect'; |
| 1348 | socket.once(connectEvent, () => { |
| 1349 | try { |
| 1350 | setupFn(); |
nothing calls this directly
no test coverage detected