From 81691c7dc5919cc04ff65ab354e47225604e1de1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 15 May 2009 01:47:17 +0200 Subject: [PATCH] Fixes to get HTTP working with new TCP API. --- src/http.cc | 13 +++++++------ src/http.js | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/http.cc b/src/http.cc index 2eb9ab412c..ae8d9d6e88 100644 --- a/src/http.cc +++ b/src/http.cc @@ -57,9 +57,6 @@ Handle HTTPConnection::v8NewClient (const Arguments& args) { HandleScope scope; - if (args[0]->IsFunction() == false) - return ThrowException(String::New("Must pass a class as the first argument.")); - Local protocol_class = Local::Cast(args[0]); new HTTPConnection(args.This(), HTTP_RESPONSE); return args.This(); } @@ -68,9 +65,6 @@ Handle HTTPConnection::v8NewServer (const Arguments& args) { HandleScope scope; - if (args[0]->IsFunction() == false) - return ThrowException(String::New("Must pass a class as the first argument.")); - Local protocol_class = Local::Cast(args[0]); new HTTPConnection(args.This(), HTTP_REQUEST); return args.This(); } @@ -349,6 +343,13 @@ HTTPServer::OnConnection (struct sockaddr *addr, socklen_t len) connection->SetAcceptor(handle_); + Handle argv[1] = { connection_handle }; + + Local ret = connection_handler->Call(handle_, 1, argv); + + if (ret.IsEmpty()) + fatal_exception(try_catch); + return connection; } diff --git a/src/http.js b/src/http.js index ad091d6a90..e5688cb757 100644 --- a/src/http.js +++ b/src/http.js @@ -51,8 +51,7 @@ node.http.Server = function (RequestHandler, options) { if (!(this instanceof node.http.Server)) throw Error("Constructor called as a function"); - function Protocol (connection) { - + function ConnectionHandler (connection) { // An array of messages for each connection. In pipelined connections // we need to keep track of the order they were sent. var messages = []; @@ -211,7 +210,6 @@ node.http.Server = function (RequestHandler, options) { } connection.onMessage = function ( ) { - puts("got onMessage"); var msg = new Message(); msg.path = ""; @@ -263,5 +261,5 @@ node.http.Server = function (RequestHandler, options) { }; } - this.__proto__.__proto__ = new node.http.LowLevelServer(Protocol, options); + this.__proto__.__proto__ = new node.http.LowLevelServer(ConnectionHandler, options); };