http: reuse noop function in socketOnError()

PR-URL: https://github.com/nodejs/node/pull/25566
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
cjihrig 2019-01-18 09:08:09 -05:00
parent 17c6b1d4f7
commit 5571c0ddeb
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -503,13 +503,14 @@ 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}${CRLF}`, 'ascii'
);
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) {