From 58ecc3de9c4d3662a9ffc92384d0db2bb2087eea Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 18 Jan 2019 09:08:09 -0500 Subject: [PATCH] http: reuse noop function in socketOnError() PR-URL: https://github.com/nodejs/node/pull/25566 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/_http_server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index dd06c9cfe3f9c0..f8aacb40452c8a 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -499,6 +499,7 @@ function onParserExecute(server, socket, parser, state, ret) { onParserExecuteCommon(server, socket, parser, state, ret, undefined); } +const noop = () => {}; const badRequestResponse = Buffer.from( `HTTP/1.1 400 ${STATUS_CODES[400]}${CRLF}` + `Connection: close${CRLF}${CRLF}`, 'ascii' @@ -506,7 +507,7 @@ const badRequestResponse = Buffer.from( function socketOnError(e) { // Ignore further errors this.removeListener('error', socketOnError); - this.on('error', () => {}); + this.on('error', noop); if (!this.server.emit('clientError', e, this)) { if (this.writable) {