diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-10-12 17:47:35 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-10-16 10:17:12 -0700 |
commit | ab037455094c9e3b9922ae2a380911b2b41ba7ce (patch) | |
tree | 3a1cfdb415ec9285e0bef2436278a1767fbd0008 /src/node_http_parser.cc | |
parent | 990141502d2056b93a62042933c574bb0d1fcdab (diff) | |
download | android-node-v8-ab037455094c9e3b9922ae2a380911b2b41ba7ce.tar.gz android-node-v8-ab037455094c9e3b9922ae2a380911b2b41ba7ce.tar.bz2 android-node-v8-ab037455094c9e3b9922ae2a380911b2b41ba7ce.zip |
http_parser: expose pause/resume method for parser
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r-- | src/node_http_parser.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 8118091180..12e9ee2fd3 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -482,6 +482,17 @@ class Parser : public WeakObject { } + template <bool should_pause> + static void Pause(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args.GetIsolate()); + HandleScope handle_scope(args.GetIsolate()); + Parser* parser = WeakObject::Unwrap<Parser>(args.This()); + // Should always be called from the same context. + assert(env == parser->env()); + http_parser_pause(&parser->parser_, should_pause); + } + + private: Local<Array> CreateHeaders() { @@ -588,6 +599,8 @@ void InitHttpParser(Handle<Object> 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<true>); + NODE_SET_PROTOTYPE_METHOD(t, "resume", Parser::Pause<false>); target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "HTTPParser"), t->GetFunction()); |