Skip to content

Commit 65d8813

Browse files
committed
fixup! http: make maximum header size configurable per-stream or per-server
1 parent a92936a commit 65d8813

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

lib/_http_client.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const {
5353
ERR_INVALID_PROTOCOL,
5454
ERR_UNESCAPED_CHARACTERS
5555
} = codes;
56+
const { validateInteger } = require('internal/validators');
5657
const { getTimerDuration } = require('internal/timers');
5758
const {
5859
DTRACE_HTTP_CLIENT_REQUEST,
@@ -178,10 +179,8 @@ function ClientRequest(input, options, cb) {
178179
}
179180

180181
const maxHeaderSize = options.maxHeaderSize;
181-
if (maxHeaderSize !== undefined && (!Number.isSafeInteger(maxHeaderSize) ||
182-
maxHeaderSize < 0)) {
183-
throw new ERR_INVALID_ARG_TYPE('maxHeaderSize', 'number', maxHeaderSize);
184-
}
182+
if (maxHeaderSize !== undefined)
183+
validateInteger(maxHeaderSize, 'maxHeaderSize', 0);
185184
this.maxHeaderSize = maxHeaderSize;
186185

187186
this.path = options.path || '/';

lib/_http_server.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const {
5858
ERR_INVALID_ARG_TYPE,
5959
ERR_INVALID_CHAR
6060
} = require('internal/errors').codes;
61+
const { validateInteger } = require('internal/validators');
6162
const Buffer = require('buffer').Buffer;
6263
const {
6364
DTRACE_HTTP_SERVER_REQUEST,
@@ -323,10 +324,8 @@ function Server(options, requestListener) {
323324
this[kServerResponse] = options.ServerResponse || ServerResponse;
324325

325326
const maxHeaderSize = options.maxHeaderSize;
326-
if (maxHeaderSize !== undefined && (!Number.isSafeInteger(maxHeaderSize) ||
327-
maxHeaderSize < 0)) {
328-
throw new ERR_INVALID_ARG_TYPE('maxHeaderSize', 'number', maxHeaderSize);
329-
}
327+
if (maxHeaderSize !== undefined)
328+
validateInteger(maxHeaderSize, 'maxHeaderSize', 0);
330329
this.maxHeaderSize = maxHeaderSize;
331330

332331
net.Server.call(this, { allowHalfOpen: true });

src/node_options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
436436
"profile generated with --heap-prof. (default: 512 * 1024)",
437437
&EnvironmentOptions::heap_prof_interval);
438438
AddOption("--max-http-header-size",
439-
"set the maximum size of HTTP headers (default: 8KB)",
439+
"set the maximum size of HTTP headers (default: 8192 (8KB))",
440440
&EnvironmentOptions::max_http_header_size,
441441
kAllowedInEnvironment);
442442
#endif // HAVE_INSPECTOR

0 commit comments

Comments
 (0)