1'use strict'; 2const common = require('../common'); 3const http = require('http'); 4 5const server = http.createServer((req, res) => { 6 res.end(); 7}).listen(0, common.mustCall(() => { 8 const agent = new http.Agent({ 9 maxSockets: 1, 10 keepAlive: true 11 }); 12 13 const port = server.address().port; 14 15 const post = http.request({ 16 agent, 17 method: 'POST', 18 port, 19 }, common.mustCall((res) => { 20 res.resume(); 21 })); 22 23 // What happens here is that the server `end`s the response before we send 24 // `something`, and the client thought that this is a green light for sending 25 // next GET request 26 post.write(Buffer.alloc(16 * 1024, 'X')); 27 setTimeout(() => { 28 post.end('something'); 29 }, 100); 30 31 http.request({ 32 agent, 33 method: 'GET', 34 port, 35 }, common.mustCall((res) => { 36 server.close(); 37 res.connection.end(); 38 })).end(); 39})); 40