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 */ 27 post.write(Buffer.alloc(16 * 1024, 'X')); 28 setTimeout(() => { 29 post.end('something'); 30 }, 100); 31 32 http.request({ 33 agent, 34 method: 'GET', 35 port, 36 }, common.mustCall((res) => { 37 server.close(); 38 res.connection.end(); 39 })).end(); 40})); 41