@@ -161,11 +161,12 @@ struct StringPtr {
161161
162162class Parser : public AsyncWrap , public StreamListener {
163163 public:
164- Parser (Environment* env, Local<Object> wrap, enum http_parser_type type)
164+ Parser (Environment* env, Local<Object> wrap, enum http_parser_type type,
165+ bool lenient)
165166 : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER),
166167 current_buffer_len_ (0 ),
167168 current_buffer_data_(nullptr ) {
168- Init (type);
169+ Init (type, lenient );
169170 }
170171
171172
@@ -383,7 +384,7 @@ class Parser : public AsyncWrap, public StreamListener {
383384 http_parser_type type =
384385 static_cast <http_parser_type>(args[0 ].As <Int32>()->Value ());
385386 CHECK (type == HTTP_REQUEST || type == HTTP_RESPONSE);
386- new Parser (env, args.This (), type);
387+ new Parser (env, args.This (), type, args[ 1 ]-> IsTrue () );
387388 }
388389
389390
@@ -475,6 +476,7 @@ class Parser : public AsyncWrap, public StreamListener {
475476
476477 static void Reinitialize (const FunctionCallbackInfo<Value>& args) {
477478 Environment* env = Environment::GetCurrent (args);
479+ bool lenient = args[2 ]->IsTrue ();
478480
479481 CHECK (args[0 ]->IsInt32 ());
480482 CHECK (args[1 ]->IsBoolean ());
@@ -493,7 +495,7 @@ class Parser : public AsyncWrap, public StreamListener {
493495 if (isReused) {
494496 parser->AsyncReset ();
495497 }
496- parser->Init (type);
498+ parser->Init (type, lenient );
497499 }
498500
499501
@@ -722,8 +724,9 @@ class Parser : public AsyncWrap, public StreamListener {
722724 }
723725
724726
725- void Init (enum http_parser_type type) {
727+ void Init (enum http_parser_type type, bool lenient ) {
726728 http_parser_init (&parser_, type);
729+ parser_.lenient_http_headers = lenient;
727730 url_.Reset ();
728731 status_message_.Reset ();
729732 num_fields_ = 0 ;
0 commit comments