diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 8118091180a..12e9ee2fd38 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -482,6 +482,17 @@ class Parser : public WeakObject { } + template + static void Pause(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args.GetIsolate()); + HandleScope handle_scope(args.GetIsolate()); + Parser* parser = WeakObject::Unwrap(args.This()); + // Should always be called from the same context. + assert(env == parser->env()); + http_parser_pause(&parser->parser_, should_pause); + } + + private: Local CreateHeaders() { @@ -588,6 +599,8 @@ void InitHttpParser(Handle target, NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute); NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish); NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize); + NODE_SET_PROTOTYPE_METHOD(t, "pause", Parser::Pause); + NODE_SET_PROTOTYPE_METHOD(t, "resume", Parser::Pause); target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "HTTPParser"), t->GetFunction());