Skip to content
Permalink
Browse files

test, http: add regression test for keepalive 'end' event

This test covers a regression where 'end' was not emitted in the case
of keepalive requests without parsing the full body.

PR-URL: #29263
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
mcollina authored and Trott committed Aug 22, 2019
1 parent a5d9288 commit b3172f834f418f4f2656d851e585f17aece73333
Showing with 29 additions and 0 deletions.
  1. +29 −0 test/parallel/test-http-server-keepalive-end.js
@@ -0,0 +1,29 @@
'use strict';

const common = require('../common');
const { createServer } = require('http');
const { connect } = require('net');

const server = createServer(common.mustCall((req, res) => {
req.on('end', common.mustCall());
res.end('hello world');
}));

server.unref();

server.listen(0, common.mustCall(() => {

const client = connect(server.address().port);

const req = [
'POST / HTTP/1.1',
`Host: localhost:${server.address().port}`,
'Connection: keep-alive',
'Content-Length: 11',
'',
'hello world',
''
].join('\r\n');

client.end(req);
}));

0 comments on commit b3172f8

Please sign in to comment.
You can’t perform that action at this time.