Skip to content

Commit

Permalink
test, http: add regression test for keepalive 'end' event
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
mcollina authored and targos committed Aug 26, 2019
1 parent f8f8754 commit 3c7a1a9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/parallel/test-http-server-keepalive-end.js
Original file line number Diff line number Diff line change
@@ -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 3c7a1a9

Please sign in to comment.