0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00
nodejs/test_client.js

34 lines
738 B
JavaScript

var c = new node.http.Client(8000, "localhost")
var req = c.get("/hello/world", [["Accept", "*/*"]]);
req.finish(function (res) {
puts("response 1: " + res.status_code.toString());
res.onBody = function (chunk) {
puts("response 1 body <" + chunk.encodeUtf8() + ">");
return true;
};
res.onBodyComplete = function () {
puts("response 1 complete!");
return true;
};
});
/*
var req = c.get("/something/else", []);
req.finish(function (res) {
puts("response 2: " + res.status_code.toString());
res.onBody = function (chunk) {
puts("response 2 body <" + chunk.encodeUtf8() + ">");
return true;
};
res.onBodyComplete = function () {
puts("response 2 complete!");
return true;
};
});
*/