11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// This test ensures that Node.js doesn't crash with an AssertionError at 51cb0ef41Sopenharmony_ci// `ServerResponse.resOnFinish` because of an out-of-order 'finish' bug in 61cb0ef41Sopenharmony_ci// pipelining. 71cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/2639 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst http = require('http'); 101cb0ef41Sopenharmony_ciconst net = require('net'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst COUNT = 10; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst server = http 151cb0ef41Sopenharmony_ci .createServer( 161cb0ef41Sopenharmony_ci common.mustCall((req, res) => { 171cb0ef41Sopenharmony_ci // Close the server, we have only one TCP connection anyway 181cb0ef41Sopenharmony_ci server.close(); 191cb0ef41Sopenharmony_ci res.writeHead(200); 201cb0ef41Sopenharmony_ci res.write('data'); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci setTimeout(function() { 231cb0ef41Sopenharmony_ci res.end(); 241cb0ef41Sopenharmony_ci }, (Math.random() * 100) | 0); 251cb0ef41Sopenharmony_ci }, COUNT) 261cb0ef41Sopenharmony_ci ) 271cb0ef41Sopenharmony_ci .listen(0, function() { 281cb0ef41Sopenharmony_ci const s = net.connect(this.address().port); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci const big = 'GET / HTTP/1.1\r\n\r\n'.repeat(COUNT); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci s.write(big); 331cb0ef41Sopenharmony_ci s.resume(); 341cb0ef41Sopenharmony_ci }); 35