Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12.x] http: runtime deprecate legacy HTTP parser #37603

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
BethGriggs marked this conversation as resolved.
Show resolved Hide resolved

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.
Expand Down
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/node_http_parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
}

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-http-parser-legacy-deprecation.js
Original file line number Diff line number Diff line change
@@ -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']
});