@@ -495,6 +495,7 @@ class Parser : public AsyncWrap, public StreamListener {
495495
496496 static void Initialize (const FunctionCallbackInfo<Value>& args) {
497497 Environment* env = Environment::GetCurrent (args);
498+ bool lenient = args[2 ]->IsTrue ();
498499
499500 CHECK (args[0 ]->IsInt32 ());
500501 CHECK (args[1 ]->IsObject ());
@@ -515,7 +516,7 @@ class Parser : public AsyncWrap, public StreamListener {
515516
516517 parser->set_provider_type (provider);
517518 parser->AsyncReset (args[1 ].As <Object>());
518- parser->Init (type);
519+ parser->Init (type, lenient );
519520 }
520521
521522 template <bool should_pause>
@@ -799,12 +800,14 @@ class Parser : public AsyncWrap, public StreamListener {
799800 }
800801
801802
802- void Init (parser_type_t type) {
803+ void Init (parser_type_t type, bool lenient ) {
803804#ifdef NODE_EXPERIMENTAL_HTTP
804805 llhttp_init (&parser_, type, &settings);
806+ llhttp_set_lenient (&parser_, lenient);
805807 header_nread_ = 0 ;
806808#else /* !NODE_EXPERIMENTAL_HTTP */
807809 http_parser_init (&parser_, type);
810+ parser_.lenient_http_headers = lenient;
808811#endif /* NODE_EXPERIMENTAL_HTTP */
809812 url_.Reset ();
810813 status_message_.Reset ();
0 commit comments