Permalink
Browse files

0.1.33 patch

Removed server check to keep compatibility with 0.1.32 (process.http is now accessed through process.binding('http'))
  • Loading branch information...
1 parent ff8c4f0 commit 4db40d9ecc72fda6bf5530e9d18e43f5c20fb002 @rauchg rauchg committed Mar 23, 2010
Showing with 83 additions and 4 deletions.
  1. +0 −4 lib/socket.io/listener.js
  2. +83 −0 patch/0.1.33.patch
@@ -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'];
View
@@ -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 (Handle<Objec
+ client_constructor_template->InstanceTemplate()->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 (Handle<Objec
+ server_constructor_template->Inherit(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<Value> HTTPConnection::ResetParse
+ }
+
+
++Handle<Value> HTTPConnection::Hijack(const Arguments& args) {
++ HandleScope scope;
++ HTTPConnection *connection = ObjectWrap::Unwrap<HTTPConnection>(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<const char*>(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<v8::Object> target);
+
+ static v8::Persistent<v8::FunctionTemplate> client_constructor_template;
+- static v8::Persistent<v8::FunctionTemplate> server_constructor_template;
++ static v8::Persistent<v8::FunctionTemplate> server_constructor_template;
+
+ protected:
+ static v8::Handle<v8::Value> NewClient (const v8::Arguments& args);
+ static v8::Handle<v8::Value> NewServer (const v8::Arguments& args);
+ static v8::Handle<v8::Value> ResetParser(const v8::Arguments& args);
++ static v8::Handle<v8::Value> 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 ();
+

0 comments on commit 4db40d9

Please sign in to comment.