Skip to content

Commit

Permalink
Backport hapijs#3624 to v16 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalouin committed Jul 10, 2019
1 parent 4885f7a commit 60bce1a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const internals = {
counter: {
min: 10000,
max: 99999
}
},
badRequestResponse: new Buffer('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii')
};


Expand Down Expand Up @@ -92,7 +93,12 @@ exports = module.exports = internals.Connection = function (server, options) {
this.listener.on('clientError', (err, socket) => {

this.server._log(['connection', 'client', 'error'], err);
socket.destroy(err);
if (socket.writable) {
socket.end(internals.badRequestResponse);
}
else {
socket.destroy(err);
}
});

// Connection information
Expand Down

0 comments on commit 60bce1a

Please sign in to comment.