[DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
dmnsgn opened this issue · 1 comments
dmnsgn commented
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);
pcwiek commented