diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-09-17 14:17:08 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-09-20 20:18:35 +0200 |
commit | ac59dc42edb721ede2e5ddc6d1e4945ee2bf1e9c (patch) | |
tree | b73ea409a56d4efc04dc452713d46222faed1d05 /test | |
parent | ba3be578d8bbca1bafc391984b0e6f037507dcbc (diff) | |
download | android-node-v8-ac59dc42edb721ede2e5ddc6d1e4945ee2bf1e9c.tar.gz android-node-v8-ac59dc42edb721ede2e5ddc6d1e4945ee2bf1e9c.tar.bz2 android-node-v8-ac59dc42edb721ede2e5ddc6d1e4945ee2bf1e9c.zip |
http: remove legacy parser
Remove the legacy `http_parser` implementation as a dependency
and all code that uses it in favor of llhttp, given that the latter
has been the default for all of Node 12 with no outstanding issues.
PR-URL: https://github.com/nodejs/node/pull/29589
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-http-parser-lazy-loaded.js | 5 | ||||
-rw-r--r-- | test/parallel/test-process-versions.js | 4 | ||||
-rw-r--r-- | test/sequential/test-http-max-http-headers.js | 9 | ||||
-rw-r--r-- | test/sequential/test-set-http-max-http-headers.js | 113 |
4 files changed, 58 insertions, 73 deletions
diff --git a/test/parallel/test-http-parser-lazy-loaded.js b/test/parallel/test-http-parser-lazy-loaded.js index a6c19f9353..3c4a7e7ce9 100644 --- a/test/parallel/test-http-parser-lazy-loaded.js +++ b/test/parallel/test-http-parser-lazy-loaded.js @@ -3,7 +3,6 @@ 'use strict'; const common = require('../common'); const { internalBinding } = require('internal/test/binding'); -const { getOptionValue } = require('internal/options'); // Monkey patch before requiring anything class DummyParser { @@ -16,9 +15,7 @@ class DummyParser { } DummyParser.REQUEST = Symbol(); -const binding = - getOptionValue('--http-parser') === 'legacy' ? - internalBinding('http_parser') : internalBinding('http_parser_llhttp'); +const binding = internalBinding('http_parser'); binding.HTTPParser = DummyParser; const assert = require('assert'); diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 83568a30d8..14484293dc 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -3,8 +3,7 @@ const common = require('../common'); const assert = require('assert'); const expected_keys = ['ares', 'brotli', 'modules', 'node', - 'uv', 'v8', 'zlib', 'nghttp2', 'napi', - 'http_parser', 'llhttp']; + 'uv', 'v8', 'zlib', 'nghttp2', 'napi', 'llhttp']; if (common.hasCrypto) { expected_keys.push('openssl'); @@ -27,7 +26,6 @@ const commonTemplate = /^\d+\.\d+\.\d+(?:-.*)?$/; assert(commonTemplate.test(process.versions.ares)); assert(commonTemplate.test(process.versions.brotli)); assert(commonTemplate.test(process.versions.llhttp)); -assert(commonTemplate.test(process.versions.http_parser)); assert(commonTemplate.test(process.versions.node)); assert(commonTemplate.test(process.versions.uv)); assert(commonTemplate.test(process.versions.zlib)); diff --git a/test/sequential/test-http-max-http-headers.js b/test/sequential/test-http-max-http-headers.js index 16704fd912..9ee4d8c352 100644 --- a/test/sequential/test-http-max-http-headers.js +++ b/test/sequential/test-http-max-http-headers.js @@ -10,7 +10,6 @@ const { getOptionValue } = require('internal/options'); console.log('pid is', process.pid); console.log('max header size is', getOptionValue('--max-http-header-size')); -console.log('current http parser is', getOptionValue('--http-parser')); // Verify that we cannot receive more than 8KB of headers. @@ -33,12 +32,8 @@ function finished(client, callback) { function fillHeaders(headers, currentSize, valid = false) { // `llhttp` counts actual header name/value sizes, excluding the whitespace // and stripped chars. - if (getOptionValue('--http-parser') === 'llhttp') { - // OK, Content-Length, 0, X-CRASH, aaa... - headers += 'a'.repeat(MAX - currentSize); - } else { - headers += 'a'.repeat(MAX - headers.length - 3); - } + // OK, Content-Length, 0, X-CRASH, aaa... + headers += 'a'.repeat(MAX - currentSize); // Generate valid headers if (valid) { diff --git a/test/sequential/test-set-http-max-http-headers.js b/test/sequential/test-set-http-max-http-headers.js index 81d9d308b9..cfe1ed6953 100644 --- a/test/sequential/test-set-http-max-http-headers.js +++ b/test/sequential/test-set-http-max-http-headers.js @@ -5,7 +5,6 @@ const assert = require('assert'); const { spawn } = require('child_process'); const path = require('path'); const testName = path.join(__dirname, 'test-http-max-http-headers.js'); -const parsers = ['legacy', 'llhttp']; const timeout = common.platformTimeout(100); @@ -15,16 +14,59 @@ function test(fn) { tests.push(fn); } -parsers.forEach((parser) => { +test(function(cb) { + console.log('running subtest expecting failure'); + + // Validate that the test fails if the max header size is too small. + const args = ['--expose-internals', + '--max-http-header-size=1024', + testName]; + const cp = spawn(process.execPath, args, { stdio: 'inherit' }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + cb(); + })); +}); + +test(function(cb) { + console.log('running subtest expecting success'); + + const env = Object.assign({}, process.env, { + NODE_DEBUG: 'http' + }); + + // Validate that the test fails if the max header size is too small. + // Validate that the test now passes if the same limit becomes large enough. + const args = ['--expose-internals', + '--max-http-header-size=1024', + testName, + '1024']; + const cp = spawn(process.execPath, args, { + env, + stdio: 'inherit' + }); + + cp.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + cb(); + })); +}); + +// Next, repeat the same checks using NODE_OPTIONS if it is supported. +if (!process.config.variables.node_without_node_options) { + const env = Object.assign({}, process.env, { + NODE_OPTIONS: '--max-http-header-size=1024' + }); + test(function(cb) { console.log('running subtest expecting failure'); // Validate that the test fails if the max header size is too small. - const args = ['--expose-internals', - `--http-parser=${parser}`, - '--max-http-header-size=1024', - testName]; - const cp = spawn(process.execPath, args, { stdio: 'inherit' }); + const args = ['--expose-internals', testName]; + const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); cp.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 1); @@ -34,23 +76,10 @@ parsers.forEach((parser) => { }); test(function(cb) { - console.log('running subtest expecting success'); - - const env = Object.assign({}, process.env, { - NODE_DEBUG: 'http' - }); - - // Validate that the test fails if the max header size is too small. - // Validate that the test now passes if the same limit becomes large enough. - const args = ['--expose-internals', - `--http-parser=${parser}`, - '--max-http-header-size=1024', - testName, - '1024']; - const cp = spawn(process.execPath, args, { - env, - stdio: 'inherit' - }); + // Validate that the test now passes if the same limit + // becomes large enough. + const args = ['--expose-internals', testName, '1024']; + const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); cp.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); @@ -58,41 +87,7 @@ parsers.forEach((parser) => { cb(); })); }); - - // Next, repeat the same checks using NODE_OPTIONS if it is supported. - if (!process.config.variables.node_without_node_options) { - const env = Object.assign({}, process.env, { - NODE_OPTIONS: `--http-parser=${parser} --max-http-header-size=1024` - }); - - test(function(cb) { - console.log('running subtest expecting failure'); - - // Validate that the test fails if the max header size is too small. - const args = ['--expose-internals', testName]; - const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); - - cp.on('close', common.mustCall((code, signal) => { - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - cb(); - })); - }); - - test(function(cb) { - // Validate that the test now passes if the same limit - // becomes large enough. - const args = ['--expose-internals', testName, '1024']; - const cp = spawn(process.execPath, args, { env, stdio: 'inherit' }); - - cp.on('close', common.mustCall((code, signal) => { - assert.strictEqual(code, 0); - assert.strictEqual(signal, null); - cb(); - })); - }); - } -}); +} function runTest() { const fn = tests.shift(); |