Skip to content

Commit b3172f8

Browse files
mcollinaTrott
authored andcommitted
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>
1 parent a5d9288 commit b3172f8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { createServer } = require('http');
5+
const { connect } = require('net');
6+
7+
const server = createServer(common.mustCall((req, res) => {
8+
req.on('end', common.mustCall());
9+
res.end('hello world');
10+
}));
11+
12+
server.unref();
13+
14+
server.listen(0, common.mustCall(() => {
15+
16+
const client = connect(server.address().port);
17+
18+
const req = [
19+
'POST / HTTP/1.1',
20+
`Host: localhost:${server.address().port}`,
21+
'Connection: keep-alive',
22+
'Content-Length: 11',
23+
'',
24+
'hello world',
25+
''
26+
].join('\r\n');
27+
28+
client.end(req);
29+
}));

0 commit comments

Comments
 (0)