| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,6 +467,7 @@ function TLSSocket(socket, opts) { | |||
| 467 | 467 | this._securePending = false; | |
| 468 | 468 | this._newSessionPending = false; | |
| 469 | 469 | this._controlReleased = false; | |
| 470 | + this.secureConnecting = true; | ||
| 470 | 471 | this._SNICallback = null; | |
| 471 | 472 | this.servername = null; | |
| 472 | 473 | this.alpnProtocol = null; | |
@@ -1029,6 +1030,7 @@ function onServerSocketSecure() { | |||
| 1029 | 1030 | ||
| 1030 | 1031 | if (!this.destroyed && this._releaseControl()) { | |
| 1031 | 1032 | debug('server emit secureConnection'); | |
| 1033 | + this.secureConnecting = false; | ||
| 1032 | 1034 | this._tlsOptions.server.emit('secureConnection', this); | |
| 1033 | 1035 | } | |
| 1034 | 1036 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1152,7 +1152,7 @@ class Http2Session extends EventEmitter { | |||
| 1152 | 1152 | socket.disableRenegotiation(); | |
| 1153 | 1153 | ||
| 1154 | 1154 | const setupFn = setupHandle.bind(this, socket, type, options); | |
| 1155 | - if (socket.connecting) { | ||
| 1155 | + if (socket.connecting || socket.secureConnecting) { | ||
| 1156 | 1156 | const connectEvent = | |
| 1157 | 1157 | socket instanceof tls.TLSSocket ? 'secureConnect' : 'connect'; | |
| 1158 | 1158 | socket.once(connectEvent, () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,80 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + | ||
| 5 | + if (!common.hasCrypto) | ||
| 6 | + common.skip('missing crypto'); | ||
| 7 | + | ||
| 8 | + const http2 = require('http2'); | ||
| 9 | + const net = require('net'); | ||
| 10 | + | ||
| 11 | + const { | ||
| 12 | + HTTP2_HEADER_PATH, | ||
| 13 | + } = http2.constants; | ||
| 14 | + | ||
| 15 | + // Create a normal session, as a control case | ||
| 16 | + function normalSession(cb) { | ||
| 17 | + http2.connect('https://google.com', (clientSession) => { | ||
| 18 | + let error = null; | ||
| 19 | + const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); | ||
| 20 | + req.on('error', (err) => { | ||
| 21 | + error = err; | ||
| 22 | + }); | ||
| 23 | + req.on('response', (_headers) => { | ||
| 24 | + req.on('data', (_chunk) => { }); | ||
| 25 | + req.on('end', () => { | ||
| 26 | + clientSession.close(); | ||
| 27 | + return cb(error); | ||
| 28 | + }); | ||
| 29 | + }); | ||
| 30 | + }); | ||
| 31 | + } | ||
| 32 | + normalSession(common.mustCall(function(err) { | ||
| 33 | + assert.ifError(err); | ||
| 34 | + })); | ||
| 35 | + | ||
| 36 | + // Create a session using a socket that has not yet finished connecting | ||
| 37 | + function socketNotFinished(done) { | ||
| 38 | + const socket2 = net.connect(443, 'google.com'); | ||
| 39 | + http2.connect('https://google.com', { socket2 }, (clientSession) => { | ||
| 40 | + let error = null; | ||
| 41 | + const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); | ||
| 42 | + req.on('error', (err) => { | ||
| 43 | + error = err; | ||
| 44 | + }); | ||
| 45 | + req.on('response', (_headers) => { | ||
| 46 | + req.on('data', (_chunk) => { }); | ||
| 47 | + req.on('end', () => { | ||
| 48 | + clientSession.close(); | ||
| 49 | + socket2.destroy(); | ||
| 50 | + return done(error); | ||
| 51 | + }); | ||
| 52 | + }); | ||
| 53 | + }); | ||
| 54 | + } | ||
| 55 | + socketNotFinished(common.mustCall(function(err) { | ||
| 56 | + assert.ifError(err); | ||
| 57 | + })); | ||
| 58 | + | ||
| 59 | + // Create a session using a socket that has finished connecting | ||
| 60 | + function socketFinished(done) { | ||
| 61 | + const socket = net.connect(443, 'google.com', () => { | ||
| 62 | + http2.connect('https://google.com', { socket }, (clientSession) => { | ||
| 63 | + let error = null; | ||
| 64 | + const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); | ||
| 65 | + req.on('error', (err) => { | ||
| 66 | + error = err; | ||
| 67 | + }); | ||
| 68 | + req.on('response', (_headers) => { | ||
| 69 | + req.on('data', (_chunk) => { }); | ||
| 70 | + req.on('end', () => { | ||
| 71 | + clientSession.close(); | ||
| 72 | + return done(error); | ||
| 73 | + }); | ||
| 74 | + }); | ||
| 75 | + }); | ||
| 76 | + }); | ||
| 77 | + } | ||
| 78 | + socketFinished(common.mustCall(function(err) { | ||
| 79 | + assert.ifError(err); | ||
| 80 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments