Skip to content

Commit

Permalink
Backport 400 back request on parse error. Closes #3960
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Jul 10, 2019
1 parent 4885f7a commit d5a4319
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 9 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: Buffer.from('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii')
};


Expand Down Expand Up @@ -92,7 +93,13 @@ 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
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"description": "HTTP Server framework",
"homepage": "http://hapijs.com",
"version": "16.8.0",
"repository": {
"type": "git",
"url": "git://github.com/hapijs/hapi"
},
"repository": "git://github.com/hapijs/hapi",
"main": "lib/index.js",
"keywords": [
"framework",
Expand Down

0 comments on commit d5a4319

Please sign in to comment.