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

[DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. #6

Open
dmnsgn opened this issue Jul 14, 2021 · 1 comment · May be fixed by #7
Open

[DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. #6

dmnsgn opened this issue Jul 14, 2021 · 1 comment · May be fixed by #7

Comments

@dmnsgn
Copy link

dmnsgn commented Jul 14, 2021

Issue

process.binding() is for use by Node.js internal code only.

See: https://nodejs.org/api/deprecations.html#DEP0111

Fix

Use: _http_common

const { methods, HTTPParser } = require("_http_common");

Example implementation in undici:
https://github.com/nodejs/undici/pull/564/files

Test equality

const assert = require("assert");

const { methods: deprecatedMethods, HTTPParser: deprecatedHTTPParser } =
  process.binding("http_parser");
const { methods, HTTPParser } = require("_http_common");

assert.deepStrictEqual(methods, deprecatedMethods);
assert.strictEqual(methods, deprecatedMethods);

assert.strictEqual(
  HTTPParser.kOnHeadersComplete,
  deprecatedHTTPParser.kOnHeadersComplete
);
assert.strictEqual(
  HTTPParser.kOnMessageComplete,
  deprecatedHTTPParser.kOnMessageComplete
);
assert.strictEqual(HTTPParser.kOnBody, deprecatedHTTPParser.kOnBody);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants