Skip to content

Commit

Permalink
http: increase default header size from 8KB to 16KB
Browse files Browse the repository at this point in the history
Fixes: #27645

PR-URL: #32520
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
  • Loading branch information
rosaxxny authored and addaleax committed Mar 30, 2020
1 parent f179a22 commit bd9f4d2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,13 @@ disappear in a non-semver-major release.
### `--max-http-header-size=size`
<!-- YAML
added: v11.6.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/32520
description: Change maximum default size of HTTP headers from 8KB to 16KB.
-->

Specify the maximum size, in bytes, of HTTP headers. Defaults to 8KB.
Specify the maximum size, in bytes, of HTTP headers. Defaults to 16KB.

### `--napi-modules`
<!-- YAML
Expand Down
4 changes: 2 additions & 2 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ changes:
* `maxHeaderSize` {number} Optionally overrides the value of
[`--max-http-header-size`][] for requests received by this server, i.e.
the maximum length of request headers in bytes.
**Default:** 8192 (8KB).
**Default:** 16384 (16KB).
* `requestListener` {Function}

* Returns: {http.Server}
Expand Down Expand Up @@ -2213,7 +2213,7 @@ changes:
* `maxHeaderSize` {number} Optionally overrides the value of
[`--max-http-header-size`][] for requests received from the server, i.e.
the maximum length of response headers in bytes.
**Default:** 8192 (8KB).
**Default:** 16384 (16KB).
* `method` {string} A string specifying the HTTP request method. **Default:**
`'GET'`.
* `path` {string} Request path. Should include query string if any.
Expand Down
2 changes: 1 addition & 1 deletion doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ This flag is inherited from V8 and is subject to change upstream. It may
disappear in a non-semver-major release.
.
.It Fl -max-http-header-size Ns = Ns Ar size
Specify the maximum size of HTTP headers in bytes. Defaults to 8KB.
Specify the maximum size of HTTP headers in bytes. Defaults to 16KB.
.
.It Fl -napi-modules
This option is a no-op.
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
&EnvironmentOptions::heap_prof_interval);
#endif // HAVE_INSPECTOR
AddOption("--max-http-header-size",
"set the maximum size of HTTP headers (default: 8192 (8KB))",
"set the maximum size of HTTP headers (default: 16384 (16KB))",
&EnvironmentOptions::max_http_header_size,
kAllowedInEnvironment);
AddOption("--redirect-warnings",
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class EnvironmentOptions : public Options {
bool expose_internals = false;
bool frozen_intrinsics = false;
std::string heap_snapshot_signal;
uint64_t max_http_header_size = 8 * 1024;
uint64_t max_http_header_size = 16 * 1024;
bool no_deprecation = false;
bool no_force_async_hooks_checks = false;
bool no_warnings = false;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-max-header-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');
const { spawnSync } = require('child_process');
const http = require('http');

assert.strictEqual(http.maxHeaderSize, 8 * 1024);
assert.strictEqual(http.maxHeaderSize, 16 * 1024);
const child = spawnSync(process.execPath, ['--max-http-header-size=10', '-p',
'http.maxHeaderSize']);
assert.strictEqual(+child.stdout.toString().trim(), 10);
4 changes: 2 additions & 2 deletions test/parallel/test-http-max-http-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');
const MAX = +(process.argv[2] || 8 * 1024); // Command line option, or 8KB.
const MAX = +(process.argv[2] || 16 * 1024); // Command line option, or 16KB.

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

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

// Verify that we cannot receive more than 8KB of headers.
// Verify that we cannot receive more than 16KB of headers.

function once(cb) {
let called = false;
Expand Down

0 comments on commit bd9f4d2

Please sign in to comment.