diff --git a/doc/api/cli.md b/doc/api/cli.md index e6d49feef624c0..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: @@ -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 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'] +});