Skip to content

Commit

Permalink
http: runtime deprecate legacy HTTP parser
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BethGriggs committed Mar 4, 2021
1 parent 6cef0e3 commit 8828d65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
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/TBD
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
4 changes: 4 additions & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const { setImmediate } = require('timers');

const { getOptionValue } = require('internal/options');

if (getOptionValue('--http-parser') === 'legacy') {
process.emitWarning('The legacy HTTP parser is deprecated.',
'DeprecationWarning', 'DEP0131');
}
const { methods, HTTPParser } =
getOptionValue('--http-parser') === 'legacy' ?
internalBinding('http_parser') : internalBinding('http_parser_llhttp');
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']
});

0 comments on commit 8828d65

Please sign in to comment.