From b2ee22f63ac78a52207e43dc9f9f00fe76ce454e Mon Sep 17 00:00:00 2001 From: Beth Griggs Date: Thu, 4 Mar 2021 17:17:47 +0000 Subject: [PATCH 1/3] 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. --- doc/api/deprecations.md | 5 ++++- src/node_http_parser_impl.h | 7 +++++++ test/parallel/test-http-parser-legacy-deprecation.js | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-http-parser-legacy-deprecation.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 8333597513a756..95a452db3d92a3 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 -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 7c39bc15c72a38..77d09a939cb72b 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 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 00000000000000..6c4c690a9b9169 --- /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'] +}); From 2d755e719eb7ede9893a253118e89fc6eec6c60f Mon Sep 17 00:00:00 2001 From: Beth Griggs Date: Mon, 8 Mar 2021 10:51:54 +0000 Subject: [PATCH 2/3] fixup! http: runtime deprecate legacy HTTP parser --- doc/api/cli.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/api/cli.md b/doc/api/cli.md index e6d49feef624c0..27cde3ce3f0f80 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -392,6 +392,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. From 89ff3af4aa902c4c58c3b47bb32d7853895fe360 Mon Sep 17 00:00:00 2001 From: Beth Griggs Date: Mon, 8 Mar 2021 11:39:35 +0000 Subject: [PATCH 3/3] fixup! http: runtime deprecate legacy HTTP parser --- doc/api/cli.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/cli.md b/doc/api/cli.md index 27cde3ce3f0f80..d36cc5100bc7cf 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` Chooses an HTTP parser library. Available values are: