summaryrefslogtreecommitdiff
path: root/lib/_http_server.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_http_server.js')
-rw-r--r--lib/_http_server.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/_http_server.js b/lib/_http_server.js
index 24ebd41bb5..5a714da6b6 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -507,6 +507,9 @@ const noop = () => {};
const badRequestResponse = Buffer.from(
`HTTP/1.1 400 ${STATUS_CODES[400]}${CRLF}${CRLF}`, 'ascii'
);
+const requestHeaderFieldsTooLargeResponse = Buffer.from(
+ `HTTP/1.1 431 ${STATUS_CODES[431]}${CRLF}${CRLF}`, 'ascii'
+);
function socketOnError(e) {
// Ignore further errors
this.removeListener('error', socketOnError);
@@ -514,7 +517,9 @@ function socketOnError(e) {
if (!this.server.emit('clientError', e, this)) {
if (this.writable) {
- this.write(badRequestResponse);
+ const response = e.code === 'HPE_HEADER_OVERFLOW' ?
+ requestHeaderFieldsTooLargeResponse : badRequestResponse;
+ this.write(response);
}
this.destroy(e);
}