11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst { createServer } = require('http'); 51cb0ef41Sopenharmony_ciconst { connect } = require('net'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Make sure that for HTTP keepalive requests, the .on('end') event is emitted 81cb0ef41Sopenharmony_ci// on the incoming request object, and that the parser instance does not hold 91cb0ef41Sopenharmony_ci// on to that request object afterwards. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst server = createServer(common.mustCall((req, res) => { 121cb0ef41Sopenharmony_ci req.on('end', common.mustCall(() => { 131cb0ef41Sopenharmony_ci const parser = req.socket.parser; 141cb0ef41Sopenharmony_ci assert.strictEqual(parser.incoming, req); 151cb0ef41Sopenharmony_ci process.nextTick(() => { 161cb0ef41Sopenharmony_ci assert.strictEqual(parser.incoming, null); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci })); 191cb0ef41Sopenharmony_ci res.end('hello world'); 201cb0ef41Sopenharmony_ci})); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciserver.unref(); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 251cb0ef41Sopenharmony_ci const client = connect(server.address().port); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci const req = [ 281cb0ef41Sopenharmony_ci 'POST / HTTP/1.1', 291cb0ef41Sopenharmony_ci `Host: localhost:${server.address().port}`, 301cb0ef41Sopenharmony_ci 'Connection: keep-alive', 311cb0ef41Sopenharmony_ci 'Content-Length: 11', 321cb0ef41Sopenharmony_ci '', 331cb0ef41Sopenharmony_ci 'hello world', 341cb0ef41Sopenharmony_ci '', 351cb0ef41Sopenharmony_ci ].join('\r\n'); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci client.end(req); 381cb0ef41Sopenharmony_ci})); 39