Skip to content

Commit

Permalink
Send bad request on parser error. Closes #3624
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Oct 19, 2017
1 parent e3d53c4 commit e9bb6cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const internals = {
{ name: 'request', spread: true, tags: true },
{ name: 'request-error', spread: true },
'response'
]
],
badRequestResponse: new Buffer('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii')
};


Expand Down Expand Up @@ -473,7 +474,13 @@ exports = module.exports = internals.Core = class {
listener.on('clientError', (err, socket) => {

this._log(['connection', 'client', 'error'], err);
socket.destroy(err);

if (socket.writable) {
socket.end(internals.badRequestResponse);
}
else {
socket.destroy(err);
}
});

return listener;
Expand Down

0 comments on commit e9bb6cf

Please sign in to comment.