diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 8333597513a756..82226d4fbe4772 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'] +});