Skip to content

Commit

Permalink
onBodyComplete was not getting called in HTTP server
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 12, 2009
1 parent 1ec9f82 commit 3a0de00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/http.cc
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/http.js
Expand Up @@ -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;
};
Expand Down Expand Up @@ -464,6 +464,7 @@ node.http.Client = function (port, host) {
res.headers = headers;

req.responseHandler(res);
return true;
};

this.onBody = function (chunk) {
Expand Down
10 changes: 6 additions & 4 deletions test/test-http.js
Expand Up @@ -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);
Expand Down

0 comments on commit 3a0de00

Please sign in to comment.