From e5965e2c3e10a3b385d75f2c29abb0dbfc344ea2 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 6 Jan 2021 21:07:37 +0100 Subject: [PATCH 1/2] http: remove unused and undocument httpAllowHalfOpen --- lib/_http_server.js | 28 ++++------------------------ lib/https.js | 2 -- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 9225ff06117859..a473722334ab8c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -386,11 +386,6 @@ function Server(options, requestListener) { this.on('request', requestListener); } - // Similar option to this. Too lazy to write my own docs. - // http://www.squid-cache.org/Doc/config/half_closed_clients/ - // https://wiki.squid-cache.org/SquidFaq/InnerWorkings#What_is_a_half-closed_filedescriptor.3F - this.httpAllowHalfOpen = false; - this.on('connection', connectionListener); this.timeout = 0; @@ -580,12 +575,7 @@ function socketOnTimeout() { } function socketOnClose(socket, state) { - debug('server socket close'); - // Mark this parser as reusable - if (socket.parser) { - freeParser(socket.parser, null, socket); - } - + freeParser(socket.parser, null, socket); abortIncoming(state.incoming); } @@ -601,19 +591,9 @@ function socketOnEnd(server, socket, parser, state) { const ret = parser.finish(); if (ret instanceof Error) { - debug('parse error'); - FunctionPrototypeCall(socketOnError, socket, ret); - return; - } - - if (!server.httpAllowHalfOpen) { - abortIncoming(state.incoming); - if (socket.writable) socket.end(); - } else if (state.outgoing.length) { - state.outgoing[state.outgoing.length - 1]._last = true; - } else if (socket._httpMessage) { - socket._httpMessage._last = true; - } else if (socket.writable) { + socket.destroy(ret); + } else { + // TODO(ronag): Does end() vs destroy() make any differenc? socket.end(); } } diff --git a/lib/https.js b/lib/https.js index a7fcf06a95f273..e4a4612780bf79 100644 --- a/lib/https.js +++ b/lib/https.js @@ -73,8 +73,6 @@ function Server(opts, requestListener) { FunctionPrototypeCall(tls.Server, this, opts, _connectionListener); - this.httpAllowHalfOpen = false; - if (requestListener) { this.addListener('request', requestListener); } From d5cde0e4ae3c03c1cf7f0ce322d627a1af782328 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 6 Jan 2021 21:19:00 +0100 Subject: [PATCH 2/2] Update lib/_http_server.js --- lib/_http_server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index a473722334ab8c..07a9984b8d5b2a 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -593,7 +593,7 @@ function socketOnEnd(server, socket, parser, state) { if (ret instanceof Error) { socket.destroy(ret); } else { - // TODO(ronag): Does end() vs destroy() make any differenc? + // TODO(ronag): Does end() vs destroy() make any difference? socket.end(); } }