Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: eb83abc7e6
Fetching contributors…

Cannot retrieve contributors at this time

84 lines (71 sloc) 3.026 kB
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 ();
Jump to Line
Something went wrong with that request. Please try again.