Skip to content

Commit 3a0de00

Browse files
committed
onBodyComplete was not getting called in HTTP server
1 parent 1ec9f82 commit 3a0de00

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/http.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ HTTPConnection::on_message_complete (http_parser *parser)
262262

263263
Local<Value> message_handler_v =
264264
connection->handle_->GetHiddenValue(MESSAGE_HANDLER_SYMBOL);
265-
Local<Object> message_handler = message_handler_v->ToObject();
266265
connection->handle_->DeleteHiddenValue(MESSAGE_HANDLER_SYMBOL);
267266

267+
Local<Object> message_handler = message_handler_v->ToObject();
268+
268269
Local<Value> on_msg_complete_v = message_handler->Get(ON_MESSAGE_COMPLETE_SYMBOL);
269-
if (on_msg_complete_v->IsFunction() == false)
270-
return 0;
270+
if (on_msg_complete_v->IsFunction() == false) return 0;
271271
Handle<Function> on_msg_complete = Handle<Function>::Cast(on_msg_complete_v);
272272

273273
TryCatch try_catch;

src/http.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ node.http.Server = function (RequestHandler, options) {
296296
return true;
297297
};
298298

299-
this.onBodyComplete = function () {
299+
this.onMessageComplete = function () {
300300
if (req.onBodyComplete)
301-
return req.onBodyComplete(chunk);
301+
return req.onBodyComplete();
302302
else
303303
return true;
304304
};
@@ -464,6 +464,7 @@ node.http.Client = function (port, host) {
464464
res.headers = headers;
465465

466466
req.responseHandler(res);
467+
return true;
467468
};
468469

469470
this.onBody = function (chunk) {

test/test-http.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ function onLoad () {
1919
this.close();
2020
}
2121

22-
res.sendHeader(200, [["Content-Type", "text/plain"]]);
23-
res.sendBody("The path was " + req.uri.path);
24-
res.finish();
25-
responses_sent += 1;
22+
req.onBodyComplete = function () {
23+
res.sendHeader(200, [["Content-Type", "text/plain"]]);
24+
res.sendBody("The path was " + req.uri.path);
25+
res.finish();
26+
responses_sent += 1;
27+
};
2628
}).listen(PORT);
2729

2830
var client = new node.http.Client(PORT);

0 commit comments

Comments
 (0)