summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeth Griggs <bgriggs@redhat.com>2021-03-04 17:17:47 +0000
committerBeth Griggs <bgriggs@redhat.com>2021-03-08 13:08:46 +0000
commita0b610450a95d2111fbd2053dc9a4c840d618ac1 (patch)
tree6ea103d1247ef1c84b6484fa22e9fdad755cf62c
parent6cef0e3678345a12044519ed90faf9d943a89892 (diff)
downloadnode-new-a0b610450a95d2111fbd2053dc9a4c840d618ac1.tar.gz
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: https://github.com/nodejs/node/pull/37603 Refs: https://github.com/nodejs/node/issues/31441 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
-rw-r--r--doc/api/cli.md6
-rw-r--r--doc/api/deprecations.md5
-rw-r--r--src/node_http_parser_impl.h7
-rw-r--r--test/parallel/test-http-parser-legacy-deprecation.js11
4 files changed, 28 insertions, 1 deletions
diff --git a/doc/api/cli.md b/doc/api/cli.md
index e6d49feef6..d36cc5100b 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -383,6 +383,10 @@ Specify the file name of the heap profile generated by `--heap-prof`.
### `--http-parser=library`
<!-- YAML
added: v11.4.0
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/37603
+ description: The legacy HTTP parser will emit a deprecation warning.
-->
Chooses an HTTP parser library. Available values are:
@@ -392,6 +396,8 @@ Chooses an HTTP parser library. Available values are:
The default is `llhttp`, unless otherwise specified when building Node.js.
+The `legacy` HTTP parser is deprecated and will emit a deprecation warning.
+
This flag exists to aid in experimentation with the internal implementation of
the Node.js http parser.
This flag is likely to become a no-op and removed at some point in the future.
diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index 8333597513..95a452db3d 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -2469,12 +2469,15 @@ Module.createRequireFromPath() is deprecated. Please use [`module.createRequire(
### DEP0131: Legacy HTTP parser
<!-- YAML
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/37603
+ description: Runtime deprecation.
- version: v12.3.0
pr-url: https://github.com/nodejs/node/pull/27498
description: Documentation-only.
-->
-Type: Documentation-only
+Type: Runtime
The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0,
is deprecated. This deprecation applies to users of the
diff --git a/src/node_http_parser_impl.h b/src/node_http_parser_impl.h
index 7c39bc15c7..77d09a939c 100644
--- a/src/node_http_parser_impl.h
+++ b/src/node_http_parser_impl.h
@@ -26,6 +26,9 @@
#include "node.h"
#include "node_buffer.h"
+#ifndef NODE_EXPERIMENTAL_HTTP
+#include "node_process.h"
+#endif /* NODE_EXPERIMENTAL_HTTP */
#include "util.h"
#include "async_wrap-inl.h"
@@ -1021,6 +1024,10 @@ void InitializeHttpParser(Local<Object> target,
#ifndef NODE_EXPERIMENTAL_HTTP
static uv_once_t init_once = UV_ONCE_INIT;
uv_once(&init_once, InitMaxHttpHeaderSizeOnce);
+ ProcessEmitDeprecationWarning(
+ env,
+ "The legacy HTTP parser is deprecated.",
+ "DEP0131").IsNothing();
#endif /* NODE_EXPERIMENTAL_HTTP */
}
diff --git a/test/parallel/test-http-parser-legacy-deprecation.js b/test/parallel/test-http-parser-legacy-deprecation.js
new file mode 100644
index 0000000000..6c4c690a9b
--- /dev/null
+++ b/test/parallel/test-http-parser-legacy-deprecation.js
@@ -0,0 +1,11 @@
+'use strict';
+const common = require('../common');
+
+// Flags: --http-parser=legacy
+require('http');
+
+common.expectWarning({
+ DeprecationWarning:
+ ['The legacy HTTP parser is deprecated.',
+ 'DEP0131']
+});