Skip to content

Commit 2cb8f24

Browse files
committed
http: switch default parser to llhttp
Refs: #24739 Fixes: #24730 PR-URL: #24870 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 951b1c3 commit 2cb8f24

File tree

7 files changed

+3
-32
lines changed

7 files changed

+3
-32
lines changed

configure.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
parser.add_option('--experimental-http-parser',
188188
action='store_true',
189189
dest='experimental_http_parser',
190-
help='use llhttp instead of http_parser by default')
190+
help='(no-op)')
191191

192192
shared_optgroup.add_option('--shared-http-parser',
193193
action='store_true',
@@ -1118,9 +1118,6 @@ def configure_node(o):
11181118
else:
11191119
o['variables']['node_target_type'] = 'executable'
11201120

1121-
o['variables']['node_experimental_http_parser'] = \
1122-
b(options.experimental_http_parser)
1123-
11241121
def configure_library(lib, output):
11251122
shared_lib = 'shared_' + lib
11261123
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))

doc/api/cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Chooses an HTTP parser library. Available values are:
129129
- `llhttp` for https://llhttp.org/
130130
- `legacy` for https://github.com/nodejs/http-parser
131131

132-
The default is `legacy`, unless otherwise specified when building Node.js.
132+
The default is `llhttp`, unless otherwise specified when building Node.js.
133133

134134
This flag exists to aid in experimentation with the internal implementation of
135135
the Node.js http parser.

node.gyp

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
'force_dynamic_crt%': 0,
1313
'node_module_version%': '',
1414
'node_shared_zlib%': 'false',
15-
'node_experimental_http_parser%': 'false',
1615
'node_shared_http_parser%': 'false',
1716
'node_shared_cares%': 'false',
1817
'node_shared_libuv%': 'false',

node.gypi

-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@
163163
],
164164
}],
165165

166-
[ 'node_experimental_http_parser=="true"', {
167-
'defines': [ 'NODE_EXPERIMENTAL_HTTP_DEFAULT' ],
168-
} ],
169-
170166
[ 'node_shared_http_parser=="false"', {
171167
'dependencies': [
172168
'deps/http_parser/http_parser.gyp:http_parser',

src/inspector_socket.cc

-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "inspector_socket.h"
22

3-
#ifdef NODE_EXPERIMENTAL_HTTP_DEFAULT
43
#define NODE_EXPERIMENTAL_HTTP
5-
#endif
64
#include "http_parser_adaptor.h"
75

86
#include "util-inl.h"
@@ -437,13 +435,8 @@ class HttpHandler : public ProtocolHandler {
437435
explicit HttpHandler(InspectorSocket* inspector, TcpHolder::Pointer tcp)
438436
: ProtocolHandler(inspector, std::move(tcp)),
439437
parsing_value_(false) {
440-
#ifdef NODE_EXPERIMENTAL_HTTP_DEFAULT
441438
llhttp_init(&parser_, HTTP_REQUEST, &parser_settings);
442439
llhttp_settings_init(&parser_settings);
443-
#else /* !NODE_EXPERIMENTAL_HTTP_DEFAULT */
444-
http_parser_init(&parser_, HTTP_REQUEST);
445-
http_parser_settings_init(&parser_settings);
446-
#endif /* NODE_EXPERIMENTAL_HTTP_DEFAULT */
447440
parser_settings.on_header_field = OnHeaderField;
448441
parser_settings.on_header_value = OnHeaderValue;
449442
parser_settings.on_message_complete = OnMessageComplete;
@@ -488,17 +481,12 @@ class HttpHandler : public ProtocolHandler {
488481

489482
void OnData(std::vector<char>* data) override {
490483
parser_errno_t err;
491-
#ifdef NODE_EXPERIMENTAL_HTTP_DEFAULT
492484
err = llhttp_execute(&parser_, data->data(), data->size());
493485

494486
if (err == HPE_PAUSED_UPGRADE) {
495487
err = HPE_OK;
496488
llhttp_resume_after_upgrade(&parser_);
497489
}
498-
#else /* !NODE_EXPERIMENTAL_HTTP_DEFAULT */
499-
http_parser_execute(&parser_, &parser_settings, data->data(), data->size());
500-
err = HTTP_PARSER_ERRNO(&parser_);
501-
#endif /* NODE_EXPERIMENTAL_HTTP_DEFAULT */
502490
data->clear();
503491
if (err != HPE_OK) {
504492
CancelHandshake();

src/node_options.cc

-4
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
111111
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
112112
AddOption("--http-parser",
113113
"Select which HTTP parser to use; either 'legacy' or 'llhttp' "
114-
#ifdef NODE_EXPERIMENTAL_HTTP_DEFAULT
115114
"(default: llhttp).",
116-
#else
117-
"(default: legacy).",
118-
#endif
119115
&EnvironmentOptions::http_parser,
120116
kAllowedInEnvironment);
121117
AddOption("--loader",

src/node_options.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@ class EnvironmentOptions : public Options {
9797
bool experimental_vm_modules = false;
9898
bool experimental_worker = false;
9999
bool expose_internals = false;
100-
std::string http_parser =
101-
#ifdef NODE_EXPERIMENTAL_HTTP_DEFAULT
102-
"llhttp";
103-
#else
104-
"legacy";
105-
#endif
100+
std::string http_parser = "llhttp";
106101
bool no_deprecation = false;
107102
bool no_force_async_hooks_checks = false;
108103
bool no_warnings = false;

0 commit comments

Comments
 (0)