diff -rup node-v0.1.32-orig/src/node_http.cc node-v0.1.32/src/node_http.cc --- node-v0.1.32-orig/src/node_http.cc 2010-03-13 13:14:00.000000000 -0800 +++ node-v0.1.32/src/node_http.cc 2010-03-13 13:23:48.000000000 -0800 @@ -57,6 +57,7 @@ HTTPConnection::Initialize (HandleInstanceTemplate()->SetInternalFieldCount(1); client_constructor_template->SetClassName(String::NewSymbol("Client")); NODE_SET_PROTOTYPE_METHOD(client_constructor_template, "resetParser", ResetParser); + NODE_SET_PROTOTYPE_METHOD(client_constructor_template, "hijack", Hijack); target->Set(String::NewSymbol("Client"), client_constructor_template->GetFunction()); t = FunctionTemplate::New(NewServer); @@ -64,6 +65,7 @@ HTTPConnection::Initialize (HandleInherit(Connection::constructor_template); server_constructor_template->InstanceTemplate()->SetInternalFieldCount(1); NODE_SET_PROTOTYPE_METHOD(server_constructor_template, "resetParser", ResetParser); + NODE_SET_PROTOTYPE_METHOD(server_constructor_template, "hijack", Hijack); server_constructor_template->SetClassName(String::NewSymbol("ServerSideConnection")); end_symbol = NODE_PSYMBOL("end"); @@ -101,6 +103,14 @@ Handle HTTPConnection::ResetParse } +Handle HTTPConnection::Hijack(const Arguments& args) { + HandleScope scope; + HTTPConnection *connection = ObjectWrap::Unwrap(args.Holder()); + connection->Hijack(); + return Undefined(); +} + + void HTTPConnection::OnReceive (const void *buf, size_t len) { @@ -109,6 +119,11 @@ HTTPConnection::OnReceive (const void *b assert(refs_); size_t nparsed; + if (hijacked) { + Connection::OnReceive(buf, len); + return; + } + nparsed = http_parser_execute(&parser_, static_cast(buf), len); if (nparsed != len) { diff -rup node-v0.1.32-orig/src/node_http.h node-v0.1.32/src/node_http.h --- node-v0.1.32-orig/src/node_http.h 2010-03-13 13:14:00.000000000 -0800 +++ node-v0.1.32/src/node_http.h 2010-03-13 13:25:05.000000000 -0800 @@ -12,17 +12,21 @@ public: static void Initialize (v8::Handle target); static v8::Persistent client_constructor_template; - static v8::Persistent server_constructor_template; + static v8::Persistent server_constructor_template; protected: static v8::Handle NewClient (const v8::Arguments& args); static v8::Handle NewServer (const v8::Arguments& args); static v8::Handle ResetParser(const v8::Arguments& args); + static v8::Handle Hijack(const v8::Arguments& args); + + bool hijacked; HTTPConnection (enum http_parser_type t) : Connection() { type_ = t; + hijacked = false; ResetParser(); } @@ -41,6 +45,10 @@ protected: parser_.data = this; } + void Hijack() { + hijacked = true; + } + void OnReceive (const void *buf, size_t len); void OnEOF ();