From ab037455094c9e3b9922ae2a380911b2b41ba7ce Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Sat, 12 Oct 2013 17:47:35 -0700 Subject: [PATCH] http_parser: expose pause/resume method for parser --- src/node_http_parser.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 8118091..12e9ee2 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()); -- 2.7.4