Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6d3afb

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
http: add maxHeaderSize property
This commit exposes the value of --max-http-header-size as a property of the http module. PR-URL: #24860 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e669733 commit b6d3afb
Copy full SHA for b6d3afb

File tree

Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+11Lines changed: 11 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,16 @@ added: v0.5.9
18941894
Global instance of `Agent` which is used as the default for all HTTP client
18951895
requests.
18961896

1897+
## http.maxHeaderSize
1898+
<!-- YAML
1899+
added: REPLACEME
1900+
-->
1901+
1902+
* {number}
1903+
1904+
Read-only property specifying the maximum allowed size of HTTP headers in bytes.
1905+
Defaults to 8KB. Configurable using the [`--max-http-header-size`][] CLI option.
1906+
18971907
## http.request(options[, callback])
18981908
## http.request(url[, options][, callback])
18991909
<!-- YAML
@@ -2079,6 +2089,7 @@ will be emitted in the following order:
20792089
Note that setting the `timeout` option or using the `setTimeout()` function will
20802090
not abort the request or do anything besides add a `'timeout'` event.
20812091

2092+
[`--max-http-header-size`]: cli.html#cli_max_http_header_size_size
20822093
[`'checkContinue'`]: #http_event_checkcontinue
20832094
[`'request'`]: #http_event_request
20842095
[`'response'`]: #http_event_response
Collapse file

‎lib/http.js‎

Copy file name to clipboardExpand all lines: lib/http.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const {
3232
Server,
3333
ServerResponse
3434
} = require('_http_server');
35+
let maxHeaderSize;
3536

3637
function createServer(opts, requestListener) {
3738
return new Server(opts, requestListener);
@@ -62,3 +63,16 @@ module.exports = {
6263
get,
6364
request
6465
};
66+
67+
Object.defineProperty(module.exports, 'maxHeaderSize', {
68+
configurable: true,
69+
enumerable: true,
70+
get() {
71+
if (maxHeaderSize === undefined) {
72+
const { getOptionValue } = require('internal/options');
73+
maxHeaderSize = getOptionValue('--max-http-header-size');
74+
}
75+
76+
return maxHeaderSize;
77+
}
78+
});
Collapse file
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const { spawnSync } = require('child_process');
6+
const http = require('http');
7+
8+
assert.strictEqual(http.maxHeaderSize, 8 * 1024);
9+
const child = spawnSync(process.execPath, ['--max-http-header-size=10', '-p',
10+
'http.maxHeaderSize']);
11+
assert.strictEqual(+child.stdout.toString().trim(), 10);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.