diff --git a/lib/socket.io/listener.js b/lib/socket.io/listener.js index 56bd2e76..1979ebff 100644 --- a/lib/socket.io/listener.js +++ b/lib/socket.io/listener.js @@ -26,10 +26,6 @@ Listener = this.Listener = Class({ this.clients = []; this.clientsIndex = {}; - if (!(this.server instanceof process.http.Server)){ - throw new Error('Please pass the result of http.createServer() to the listener'); - } - var listener = (this.server._events['request'] instanceof Array) ? this.server._events['request'][0] : this.server._events['request']; diff --git a/patch/0.1.33.patch b/patch/0.1.33.patch new file mode 100644 index 00000000..1eeb7495 --- /dev/null +++ b/patch/0.1.33.patch @@ -0,0 +1,83 @@ +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 (); +