mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-11 07:58:13 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4db40d9ecc |
@@ -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'];
|
||||
|
||||
83
patch/0.1.33.patch
Normal file
83
patch/0.1.33.patch
Normal file
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user