Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added nodejs patch

  • Loading branch information...
commit a53c9f1d817a107eb1aec42584d662c2cfe88b6e 1 parent d315150
@zimbatm authored
View
90 patches/0001-Added-hijack-method-to-http.Request.prototype.connec.patch
@@ -0,0 +1,90 @@
+From 37a975b92da63d9141690d379adfeb827dbd097c Mon Sep 17 00:00:00 2001
+From: Pfenniger Jonas <zimbatm@Guybrush.local>
+Date: Fri, 25 Dec 2009 23:51:00 +0100
+Subject: [PATCH] Added hijack method to http.Request.prototype.connection
+
+---
+ src/node_http.cc | 14 ++++++++++++++
+ src/node_http.h | 8 ++++++++
+ 2 files changed, 22 insertions(+), 0 deletions(-)
+
+diff --git a/src/node_http.cc b/src/node_http.cc
+index 5ccc53b..b5f9dd8 100644
+--- a/src/node_http.cc
++++ b/src/node_http.cc
+@@ -40,6 +40,7 @@ HTTPConnection::Initialize (Handle<Object> target)
+ 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);
+@@ -47,6 +48,7 @@ HTTPConnection::Initialize (Handle<Object> target)
+ 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"));
+
+ method_symbol = NODE_PSYMBOL("method");
+@@ -85,6 +87,13 @@ Handle<Value> HTTPConnection::ResetParser(const Arguments& args) {
+ return Undefined();
+ }
+
++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)
+@@ -94,6 +103,11 @@ HTTPConnection::OnReceive (const void *buf, size_t len)
+ assert(refs_);
+ size_t nparsed;
+
++ if (hijacked) {
++ Connection::OnReceive(buf, len);
++ return;
++ }
++
+ if (type_ == HTTP_REQUEST) {
+ nparsed = http_parse_requests(&parser_, static_cast<const char*>(buf), len);
+ } else {
+diff --git a/src/node_http.h b/src/node_http.h
+index 1e36df0..f8b1112 100644
+--- a/src/node_http.h
++++ b/src/node_http.h
+@@ -20,11 +20,15 @@ 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_connection_type t)
+ : Connection()
+ {
+ type_ = t;
++ hijacked = false;
+ ResetParser();
+ }
+
+@@ -42,6 +46,10 @@ protected:
+ parser_.on_message_complete = on_message_complete;
+ parser_.data = this;
+ }
++
++ void Hijack() {
++ hijacked = true;
++ }
+
+ void OnReceive (const void *buf, size_t len);
+ void OnEOF ();
+--
+1.6.6
+
Please sign in to comment.
Something went wrong with that request. Please try again.