Skip to content

Commit b2ee22f

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.
1 parent 6cef0e3 commit b2ee22f

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

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)