11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst http = require('http'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst server = http.createServer(); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciserver.on('upgrade', common.mustCall((request, socket) => { 101cb0ef41Sopenharmony_ci assert.strictEqual(socket.parser, null); 111cb0ef41Sopenharmony_ci socket.write([ 121cb0ef41Sopenharmony_ci 'HTTP/1.1 101 Switching Protocols', 131cb0ef41Sopenharmony_ci 'Connection: Upgrade', 141cb0ef41Sopenharmony_ci 'Upgrade: WebSocket', 151cb0ef41Sopenharmony_ci '\r\n', 161cb0ef41Sopenharmony_ci ].join('\r\n')); 171cb0ef41Sopenharmony_ci})); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciserver.listen(common.mustCall(() => { 201cb0ef41Sopenharmony_ci const request = http.get({ 211cb0ef41Sopenharmony_ci port: server.address().port, 221cb0ef41Sopenharmony_ci headers: { 231cb0ef41Sopenharmony_ci Connection: 'Upgrade', 241cb0ef41Sopenharmony_ci Upgrade: 'WebSocket' 251cb0ef41Sopenharmony_ci } 261cb0ef41Sopenharmony_ci }); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci request.on('upgrade', common.mustCall((response, socket) => { 291cb0ef41Sopenharmony_ci assert.strictEqual(socket.parser, null); 301cb0ef41Sopenharmony_ci socket.destroy(); 311cb0ef41Sopenharmony_ci server.close(); 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci})); 34