mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
http: make parser choice a runtime flag
Add a `--http-parser=llhttp` vs `--http-parser=traditional` command line switch, to make testing and comparing the new llhttp-based implementation easier. PR-URL: https://github.com/nodejs/node/pull/24739 Refs: https://github.com/nodejs/node/issues/24730 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
This commit is contained in:
parent
7bcbf044dd
commit
aa943d098e
29 changed files with 157 additions and 85 deletions
|
@ -3,6 +3,7 @@
|
|||
'use strict';
|
||||
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
// Monkey patch before requiring anything
|
||||
class DummyParser {
|
||||
|
@ -11,7 +12,11 @@ class DummyParser {
|
|||
}
|
||||
}
|
||||
DummyParser.REQUEST = Symbol();
|
||||
internalBinding('http_parser').HTTPParser = DummyParser;
|
||||
|
||||
const binding =
|
||||
getOptionValue('--http-parser') === 'legacy' ?
|
||||
internalBinding('http_parser') : internalBinding('http_parser_llhttp');
|
||||
binding.HTTPParser = DummyParser;
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue