Skip to content

Commit bd9f4d2

Browse files
rosaxxnyaddaleax
authored andcommitted
http: increase default header size from 8KB to 16KB
Fixes: #27645 PR-URL: #32520 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent f179a22 commit bd9f4d2

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

doc/api/cli.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,13 @@ disappear in a non-semver-major release.
440440
### `--max-http-header-size=size`
441441
<!-- YAML
442442
added: v11.6.0
443+
changes:
444+
- version: REPLACEME
445+
pr-url: https://github.com/nodejs/node/pull/32520
446+
description: Change maximum default size of HTTP headers from 8KB to 16KB.
443447
-->
444448

445-
Specify the maximum size, in bytes, of HTTP headers. Defaults to 8KB.
449+
Specify the maximum size, in bytes, of HTTP headers. Defaults to 16KB.
446450

447451
### `--napi-modules`
448452
<!-- YAML

doc/api/http.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ changes:
20592059
* `maxHeaderSize` {number} Optionally overrides the value of
20602060
[`--max-http-header-size`][] for requests received by this server, i.e.
20612061
the maximum length of request headers in bytes.
2062-
**Default:** 8192 (8KB).
2062+
**Default:** 16384 (16KB).
20632063
* `requestListener` {Function}
20642064

20652065
* Returns: {http.Server}
@@ -2213,7 +2213,7 @@ changes:
22132213
* `maxHeaderSize` {number} Optionally overrides the value of
22142214
[`--max-http-header-size`][] for requests received from the server, i.e.
22152215
the maximum length of response headers in bytes.
2216-
**Default:** 8192 (8KB).
2216+
**Default:** 16384 (16KB).
22172217
* `method` {string} A string specifying the HTTP request method. **Default:**
22182218
`'GET'`.
22192219
* `path` {string} Request path. Should include query string if any.

doc/node.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ This flag is inherited from V8 and is subject to change upstream. It may
244244
disappear in a non-semver-major release.
245245
.
246246
.It Fl -max-http-header-size Ns = Ns Ar size
247-
Specify the maximum size of HTTP headers in bytes. Defaults to 8KB.
247+
Specify the maximum size of HTTP headers in bytes. Defaults to 16KB.
248248
.
249249
.It Fl -napi-modules
250250
This option is a no-op.

src/node_options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
422422
&EnvironmentOptions::heap_prof_interval);
423423
#endif // HAVE_INSPECTOR
424424
AddOption("--max-http-header-size",
425-
"set the maximum size of HTTP headers (default: 8192 (8KB))",
425+
"set the maximum size of HTTP headers (default: 16384 (16KB))",
426426
&EnvironmentOptions::max_http_header_size,
427427
kAllowedInEnvironment);
428428
AddOption("--redirect-warnings",

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class EnvironmentOptions : public Options {
116116
bool expose_internals = false;
117117
bool frozen_intrinsics = false;
118118
std::string heap_snapshot_signal;
119-
uint64_t max_http_header_size = 8 * 1024;
119+
uint64_t max_http_header_size = 16 * 1024;
120120
bool no_deprecation = false;
121121
bool no_force_async_hooks_checks = false;
122122
bool no_warnings = false;

test/parallel/test-http-max-header-size.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const assert = require('assert');
55
const { spawnSync } = require('child_process');
66
const http = require('http');
77

8-
assert.strictEqual(http.maxHeaderSize, 8 * 1024);
8+
assert.strictEqual(http.maxHeaderSize, 16 * 1024);
99
const child = spawnSync(process.execPath, ['--max-http-header-size=10', '-p',
1010
'http.maxHeaderSize']);
1111
assert.strictEqual(+child.stdout.toString().trim(), 10);

test/parallel/test-http-max-http-headers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ const common = require('../common');
44
const assert = require('assert');
55
const http = require('http');
66
const net = require('net');
7-
const MAX = +(process.argv[2] || 8 * 1024); // Command line option, or 8KB.
7+
const MAX = +(process.argv[2] || 16 * 1024); // Command line option, or 16KB.
88

99
const { getOptionValue } = require('internal/options');
1010

1111
console.log('pid is', process.pid);
1212
console.log('max header size is', getOptionValue('--max-http-header-size'));
1313

14-
// Verify that we cannot receive more than 8KB of headers.
14+
// Verify that we cannot receive more than 16KB of headers.
1515

1616
function once(cb) {
1717
let called = false;

0 commit comments

Comments
 (0)