| 32 | |
| 33 | // Create a session using a socket that has not yet finished connecting |
| 34 | function socketNotFinished(done) { |
| 35 | const socket2 = net.connect(443, 'google.com'); |
| 36 | http2.connect('https://google.com', { socket2 }, (clientSession) => { |
| 37 | let error = null; |
| 38 | const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' }); |
| 39 | req.on('error', (err) => { |
| 40 | error = err; |
| 41 | }); |
| 42 | req.on('response', (_headers) => { |
| 43 | req.on('data', (_chunk) => { }); |
| 44 | req.on('end', () => { |
| 45 | clientSession.close(); |
| 46 | socket2.destroy(); |
| 47 | return done(error); |
| 48 | }); |
| 49 | }); |
| 50 | }); |
| 51 | } |
| 52 | socketNotFinished(common.mustSucceed()); |
| 53 | |
| 54 | // Create a session using a socket that has finished connecting |