0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

http_parser: expose pause/resume method for parser

This commit is contained in:
Timothy J Fontaine 2013-10-12 17:47:35 -07:00 committed by isaacs
parent 990141502d
commit ab03745509

View File

@ -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());