11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst http = require('http'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst server = http.createServer((req, res) => { 61cb0ef41Sopenharmony_ci res.end(); 71cb0ef41Sopenharmony_ci}).listen(0, common.mustCall(() => { 81cb0ef41Sopenharmony_ci const agent = new http.Agent({ 91cb0ef41Sopenharmony_ci maxSockets: 1, 101cb0ef41Sopenharmony_ci keepAlive: true 111cb0ef41Sopenharmony_ci }); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci const port = server.address().port; 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const post = http.request({ 161cb0ef41Sopenharmony_ci agent, 171cb0ef41Sopenharmony_ci method: 'POST', 181cb0ef41Sopenharmony_ci port, 191cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 201cb0ef41Sopenharmony_ci res.resume(); 211cb0ef41Sopenharmony_ci })); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci // What happens here is that the server `end`s the response before we send 241cb0ef41Sopenharmony_ci // `something`, and the client thought that this is a green light for sending 251cb0ef41Sopenharmony_ci // next GET request 261cb0ef41Sopenharmony_ci post.write(Buffer.alloc(16 * 1024, 'X')); 271cb0ef41Sopenharmony_ci setTimeout(() => { 281cb0ef41Sopenharmony_ci post.end('something'); 291cb0ef41Sopenharmony_ci }, 100); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci http.request({ 321cb0ef41Sopenharmony_ci agent, 331cb0ef41Sopenharmony_ci method: 'GET', 341cb0ef41Sopenharmony_ci port, 351cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 361cb0ef41Sopenharmony_ci server.close(); 371cb0ef41Sopenharmony_ci res.connection.end(); 381cb0ef41Sopenharmony_ci })).end(); 391cb0ef41Sopenharmony_ci})); 40