Skip to content

Commit a0b6104

Browse files
committed
http: runtime deprecate legacy HTTP parser
The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0, is deprecated. The legacy HTTP parser cannot be guaranteed to be supported after April 2021. This commit introduces a deprecation warning for the legacy HTTP parser. PR-URL: #37603 Refs: #31441 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 6cef0e3 commit a0b6104

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

doc/api/cli.md

+6
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ Specify the file name of the heap profile generated by `--heap-prof`.
383383
### `--http-parser=library`
384384
<!-- YAML
385385
added: v11.4.0
386+
changes:
387+
- version: REPLACEME
388+
pr-url: https://github.com/nodejs/node/pull/37603
389+
description: The legacy HTTP parser will emit a deprecation warning.
386390
-->
387391

388392
Chooses an HTTP parser library. Available values are:
@@ -392,6 +396,8 @@ Chooses an HTTP parser library. Available values are:
392396

393397
The default is `llhttp`, unless otherwise specified when building Node.js.
394398

399+
The `legacy` HTTP parser is deprecated and will emit a deprecation warning.
400+
395401
This flag exists to aid in experimentation with the internal implementation of
396402
the Node.js http parser.
397403
This flag is likely to become a no-op and removed at some point in the future.

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2469,12 +2469,15 @@ Module.createRequireFromPath() is deprecated. Please use [`module.createRequire(
24692469
### DEP0131: Legacy HTTP parser
24702470
<!-- YAML
24712471
changes:
2472+
- version: REPLACEME
2473+
pr-url: https://github.com/nodejs/node/pull/37603
2474+
description: Runtime deprecation.
24722475
- version: v12.3.0
24732476
pr-url: https://github.com/nodejs/node/pull/27498
24742477
description: Documentation-only.
24752478
-->
24762479

2477-
Type: Documentation-only
2480+
Type: Runtime
24782481

24792482
The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0,
24802483
is deprecated. This deprecation applies to users of the

src/node_http_parser_impl.h

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
#include "node.h"
2828
#include "node_buffer.h"
29+
#ifndef NODE_EXPERIMENTAL_HTTP
30+
#include "node_process.h"
31+
#endif /* NODE_EXPERIMENTAL_HTTP */
2932
#include "util.h"
3033

3134
#include "async_wrap-inl.h"
@@ -1021,6 +1024,10 @@ void InitializeHttpParser(Local<Object> target,
10211024
#ifndef NODE_EXPERIMENTAL_HTTP
10221025
static uv_once_t init_once = UV_ONCE_INIT;
10231026
uv_once(&init_once, InitMaxHttpHeaderSizeOnce);
1027+
ProcessEmitDeprecationWarning(
1028+
env,
1029+
"The legacy HTTP parser is deprecated.",
1030+
"DEP0131").IsNothing();
10241031
#endif /* NODE_EXPERIMENTAL_HTTP */
10251032
}
10261033

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
// Flags: --http-parser=legacy
5+
require('http');
6+
7+
common.expectWarning({
8+
DeprecationWarning:
9+
['The legacy HTTP parser is deprecated.',
10+
'DEP0131']
11+
});

0 commit comments

Comments
 (0)