Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54635f5

Browse filesBrowse files
JimblyMylesBorins
authored andcommitted
http: fix monkey-patching of http_parser
Fixes inability to monkey-patch the HTTP Parser on Node v12.x. This is not an issue on Node v13+ since the parser was renamed back to the old (already monkey-patchable) `http_parser` name, however the test in master could also use updating. Fixes: creationix/http-parser-js#65 PR-URL: #30222 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 008ac37 commit 54635f5
Copy full SHA for 54635f5

File tree

Expand file treeCollapse file tree

2 files changed

+8
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/loaders.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/loaders.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const internalBindingWhitelist = new SafeSet([
7575
'fs',
7676
'fs_event_wrap',
7777
'http_parser',
78+
'http_parser_llhttp',
7879
'icu',
7980
'inspector',
8081
'js_stream',
Collapse file

‎test/parallel/test-http-parser-lazy-loaded.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-parser-lazy-loaded.js
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict';
44
const common = require('../common');
5-
const { internalBinding } = require('internal/test/binding');
65
const { getOptionValue } = require('internal/options');
76

87
// Monkey patch before requiring anything
@@ -16,9 +15,12 @@ class DummyParser {
1615
}
1716
DummyParser.REQUEST = Symbol();
1817

18+
// Note: using process.binding instead of internalBinding because this test is
19+
// verifying that user applications are still able to monkey-patch the
20+
// http_parser module.
1921
const binding =
2022
getOptionValue('--http-parser') === 'legacy' ?
21-
internalBinding('http_parser') : internalBinding('http_parser_llhttp');
23+
process.binding('http_parser') : process.binding('http_parser_llhttp');
2224
binding.HTTPParser = DummyParser;
2325

2426
const assert = require('assert');
@@ -34,7 +36,9 @@ assert.strictEqual(parser.test_type, DummyParser.REQUEST);
3436
if (process.argv[2] !== 'child') {
3537
// Also test in a child process with IPC (specific case of https://github.com/nodejs/node/issues/23716)
3638
const child = spawn(process.execPath, [
37-
'--expose-internals', __filename, 'child'
39+
'--expose-internals',
40+
`--http-parser=${getOptionValue('--http-parser')}`,
41+
__filename, 'child'
3842
], {
3943
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
4044
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.