11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst tls = require('tls'); 71cb0ef41Sopenharmony_ciconst http = require('http'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Tests that, after the HTTP parser stopped owning a socket that emits an 101cb0ef41Sopenharmony_ci// 'upgrade' event, another C++ stream can start owning it (e.g. a TLSSocket). 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustNotCall()); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciserver.on('upgrade', common.mustCall((request, socket, head) => { 151cb0ef41Sopenharmony_ci // This should not crash. 161cb0ef41Sopenharmony_ci new tls.TLSSocket(socket); 171cb0ef41Sopenharmony_ci server.close(); 181cb0ef41Sopenharmony_ci socket.destroy(); 191cb0ef41Sopenharmony_ci})); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 221cb0ef41Sopenharmony_ci http.get({ 231cb0ef41Sopenharmony_ci port: server.address().port, 241cb0ef41Sopenharmony_ci headers: { 251cb0ef41Sopenharmony_ci 'Connection': 'Upgrade', 261cb0ef41Sopenharmony_ci 'Upgrade': 'websocket' 271cb0ef41Sopenharmony_ci } 281cb0ef41Sopenharmony_ci }).on('error', () => {}); 291cb0ef41Sopenharmony_ci})); 30