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
|
@ -1,11 +1,13 @@
|
|||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const net = require('net');
|
||||
const MAX = 8 * 1024; // 8KB
|
||||
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
// Verify that we cannot receive more than 8KB of headers.
|
||||
|
||||
function once(cb) {
|
||||
|
@ -27,7 +29,7 @@ function finished(client, callback) {
|
|||
function fillHeaders(headers, currentSize, valid = false) {
|
||||
// llhttp counts actual header name/value sizes, excluding the whitespace and
|
||||
// stripped chars.
|
||||
if (process.versions.hasOwnProperty('llhttp')) {
|
||||
if (getOptionValue('--http-parser') === 'llhttp') {
|
||||
// OK, Content-Length, 0, X-CRASH, aaa...
|
||||
headers += 'a'.repeat(MAX - currentSize);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue