@@ -240,6 +240,9 @@ std::string icu_data_dir; // NOLINT(runtime/string)
240240
241241uint64_t max_http_header_size = 8 * 1024 ;
242242
243+ // Set in node.cc by ParseArgs when --insecure-http-parser is used.
244+ bool insecure_http_parser = false ;
245+
243246// used by C++ modules as well
244247bool no_deprecation = false ;
245248
@@ -3265,6 +3268,11 @@ void SetupProcessObject(Environment* env,
32653268 preload_modules.clear ();
32663269 }
32673270
3271+ // --insecure-http-parser
3272+ if (insecure_http_parser) {
3273+ READONLY_PROPERTY (process, " insecureHTTPParser" , True (env->isolate ()));
3274+ }
3275+
32683276 // --no-deprecation
32693277 if (no_deprecation) {
32703278 READONLY_PROPERTY (process, " noDeprecation" , True (env->isolate ()));
@@ -3539,6 +3547,8 @@ static void PrintHelp() {
35393547 " --inspect-port=[host:]port\n "
35403548 " set host:port for inspector\n "
35413549#endif
3550+ " --insecure-http-parser use an insecure HTTP parser that\n "
3551+ " accepts invalid HTTP headers\n "
35423552 " --no-deprecation silence deprecation warnings\n "
35433553 " --max-http-header-size Specify the maximum size of HTTP\n "
35443554 " headers in bytes. Defaults to 8KB.\n "
@@ -3686,6 +3696,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
36863696 static const char * whitelist[] = {
36873697 // Node options, sorted in `node --help` order for ease of comparison.
36883698 " --require" , " -r" ,
3699+ " --insecure-http-parser" ,
36893700 " --inspect" ,
36903701 " --inspect-brk" ,
36913702 " --inspect-port" ,
@@ -3832,6 +3843,8 @@ static void ParseArgs(int* argc,
38323843 syntax_check_only = true ;
38333844 } else if (strcmp (arg, " --interactive" ) == 0 || strcmp (arg, " -i" ) == 0 ) {
38343845 force_repl = true ;
3846+ } else if (strcmp (arg, " --insecure-http-parser" ) == 0 ) {
3847+ insecure_http_parser = true ;
38353848 } else if (strcmp (arg, " --no-deprecation" ) == 0 ) {
38363849 no_deprecation = true ;
38373850 } else if (strcmp (arg, " --napi-modules" ) == 0 ) {
0 commit comments