diff --git a/src/http.cc b/src/http.cc index f5e057044..03e0d058e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -262,12 +262,12 @@ HTTPConnection::on_message_complete (http_parser *parser) Local message_handler_v = connection->handle_->GetHiddenValue(MESSAGE_HANDLER_SYMBOL); - Local message_handler = message_handler_v->ToObject(); connection->handle_->DeleteHiddenValue(MESSAGE_HANDLER_SYMBOL); + Local message_handler = message_handler_v->ToObject(); + Local on_msg_complete_v = message_handler->Get(ON_MESSAGE_COMPLETE_SYMBOL); - if (on_msg_complete_v->IsFunction() == false) - return 0; + if (on_msg_complete_v->IsFunction() == false) return 0; Handle on_msg_complete = Handle::Cast(on_msg_complete_v); TryCatch try_catch; diff --git a/src/http.js b/src/http.js index e05d6f9ec..d099c480e 100644 --- a/src/http.js +++ b/src/http.js @@ -296,9 +296,9 @@ node.http.Server = function (RequestHandler, options) { return true; }; - this.onBodyComplete = function () { + this.onMessageComplete = function () { if (req.onBodyComplete) - return req.onBodyComplete(chunk); + return req.onBodyComplete(); else return true; }; @@ -464,6 +464,7 @@ node.http.Client = function (port, host) { res.headers = headers; req.responseHandler(res); + return true; }; this.onBody = function (chunk) { diff --git a/test/test-http.js b/test/test-http.js index 044e44443..7d30d4d00 100644 --- a/test/test-http.js +++ b/test/test-http.js @@ -19,10 +19,12 @@ function onLoad () { this.close(); } - res.sendHeader(200, [["Content-Type", "text/plain"]]); - res.sendBody("The path was " + req.uri.path); - res.finish(); - responses_sent += 1; + req.onBodyComplete = function () { + res.sendHeader(200, [["Content-Type", "text/plain"]]); + res.sendBody("The path was " + req.uri.path); + res.finish(); + responses_sent += 1; + }; }).listen(PORT); var client = new node.http.Client(PORT);