11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst { mustCall } = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst http = require('http'); 51cb0ef41Sopenharmony_ciconst net = require('net'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/17789 - a connection upgrade response 81cb0ef41Sopenharmony_ci// that has a Transfer-Encoding header and a body whose first byte is > 127 91cb0ef41Sopenharmony_ci// triggers a bug where said byte is skipped over. 101cb0ef41Sopenharmony_cinet.createServer(mustCall(function(conn) { 111cb0ef41Sopenharmony_ci conn.write('HTTP/1.1 101 Switching Protocols\r\n' + 121cb0ef41Sopenharmony_ci 'Connection: upgrade\r\n' + 131cb0ef41Sopenharmony_ci 'Transfer-Encoding: chunked\r\n' + 141cb0ef41Sopenharmony_ci 'Upgrade: websocket\r\n' + 151cb0ef41Sopenharmony_ci '\r\n' + 161cb0ef41Sopenharmony_ci '\u0080', 'latin1'); 171cb0ef41Sopenharmony_ci this.close(); 181cb0ef41Sopenharmony_ci})).listen(0, mustCall(function() { 191cb0ef41Sopenharmony_ci http.get({ 201cb0ef41Sopenharmony_ci host: this.address().host, 211cb0ef41Sopenharmony_ci port: this.address().port, 221cb0ef41Sopenharmony_ci headers: { 'Connection': 'upgrade', 'Upgrade': 'websocket' }, 231cb0ef41Sopenharmony_ci }).on('upgrade', mustCall((res, conn, head) => { 241cb0ef41Sopenharmony_ci assert.strictEqual(head.length, 1); 251cb0ef41Sopenharmony_ci assert.strictEqual(head[0], 128); 261cb0ef41Sopenharmony_ci conn.destroy(); 271cb0ef41Sopenharmony_ci })); 281cb0ef41Sopenharmony_ci})); 29