Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

onBodyComplete was not getting called in HTTP server

  • Loading branch information...
commit 3a0de007aacf065da92ce625ef9abf484ee16ba2 1 parent 1ec9f82
@ry ry authored
Showing with 12 additions and 9 deletions.
  1. +3 −3 src/http.cc
  2. +3 −2 src/http.js
  3. +6 −4 test/test-http.js
View
6 src/http.cc
@@ -262,12 +262,12 @@ HTTPConnection::on_message_complete (http_parser *parser)
Local<Value> message_handler_v =
connection->handle_->GetHiddenValue(MESSAGE_HANDLER_SYMBOL);
- Local<Object> message_handler = message_handler_v->ToObject();
connection->handle_->DeleteHiddenValue(MESSAGE_HANDLER_SYMBOL);
+ Local<Object> message_handler = message_handler_v->ToObject();
+
Local<Value> 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<Function> on_msg_complete = Handle<Function>::Cast(on_msg_complete_v);
TryCatch try_catch;
View
5 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) {
View
10 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);
Please sign in to comment.
Something went wrong with that request. Please try again.