@@ -501,6 +501,7 @@ class Parser : public AsyncWrap, public StreamListener {
501501
502502 static void Initialize (const FunctionCallbackInfo<Value>& args) {
503503 Environment* env = Environment::GetCurrent (args);
504+ bool lenient = args[2 ]->IsTrue ();
504505
505506 CHECK (args[0 ]->IsInt32 ());
506507 CHECK (args[1 ]->IsObject ());
@@ -521,7 +522,7 @@ class Parser : public AsyncWrap, public StreamListener {
521522
522523 parser->set_provider_type (provider);
523524 parser->AsyncReset (args[1 ].As <Object>());
524- parser->Init (type);
525+ parser->Init (type, lenient );
525526 }
526527
527528 template <bool should_pause>
@@ -805,12 +806,14 @@ class Parser : public AsyncWrap, public StreamListener {
805806 }
806807
807808
808- void Init (parser_type_t type) {
809+ void Init (parser_type_t type, bool lenient ) {
809810#ifdef NODE_EXPERIMENTAL_HTTP
810811 llhttp_init (&parser_, type, &settings);
812+ llhttp_set_lenient (&parser_, lenient);
811813 header_nread_ = 0 ;
812814#else /* !NODE_EXPERIMENTAL_HTTP */
813815 http_parser_init (&parser_, type);
816+ parser_.lenient_http_headers = lenient;
814817#endif /* NODE_EXPERIMENTAL_HTTP */
815818 url_.Reset ();
816819 status_message_.Reset ();
0 commit comments