From 0eb3ce34cf8f788cea7b34fdd01ccad9e054e90e Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 22 Aug 2019 08:39:07 +0200 Subject: [PATCH 1/2] Revert "http: reset parser.incoming when server response is finished" This reverts commit 779a05d5d1bfe2eeb05386f6415d36f80ca0b3b5. --- lib/_http_server.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 2c48ab9191846b..862b7c970bda8e 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -618,8 +618,6 @@ function resOnFinish(req, res, socket, state, server) { assert(state.incoming.length === 0 || state.incoming[0] === req); state.incoming.shift(); - // Reset the .incoming property so that the request object can be gc'ed. - if (socket.parser) socket.parser.incoming = null; // If the user never called req.read(), and didn't pipe() or // .resume() or .on('data'), then we call req._dump() so that the From 3bef00e8b6e89df22d1b6ef9e5b7478551ae6148 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 22 Aug 2019 11:42:46 +0200 Subject: [PATCH 2/2] 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. --- .../test-http-server-keepalive-end.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/parallel/test-http-server-keepalive-end.js diff --git a/test/parallel/test-http-server-keepalive-end.js b/test/parallel/test-http-server-keepalive-end.js new file mode 100644 index 00000000000000..1e3a44d368a020 --- /dev/null +++ b/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); +}));