11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst Countdown = require('../common/countdown'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// This test ensures Node.js doesn't behave erratically when receiving pipelined 61cb0ef41Sopenharmony_ci// requests 71cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/3332 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst http = require('http'); 101cb0ef41Sopenharmony_ciconst net = require('net'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst big = Buffer.alloc(16 * 1024, 'A'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst COUNT = 1e4; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst countdown = new Countdown(COUNT, () => { 171cb0ef41Sopenharmony_ci server.close(); 181cb0ef41Sopenharmony_ci client.end(); 191cb0ef41Sopenharmony_ci}); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cilet client; 221cb0ef41Sopenharmony_ciconst server = http 231cb0ef41Sopenharmony_ci .createServer(function(req, res) { 241cb0ef41Sopenharmony_ci res.end(big, function() { 251cb0ef41Sopenharmony_ci countdown.dec(); 261cb0ef41Sopenharmony_ci }); 271cb0ef41Sopenharmony_ci }) 281cb0ef41Sopenharmony_ci .listen(0, function() { 291cb0ef41Sopenharmony_ci const req = 'GET / HTTP/1.1\r\n\r\n'.repeat(COUNT); 301cb0ef41Sopenharmony_ci client = net.connect(this.address().port, function() { 311cb0ef41Sopenharmony_ci client.write(req); 321cb0ef41Sopenharmony_ci }); 331cb0ef41Sopenharmony_ci client.resume(); 341cb0ef41Sopenharmony_ci }); 35