2009-05-19 13:12:46 +02:00
|
|
|
var c = new node.http.Client(8000, "localhost")
|
|
|
|
|
|
|
|
var req = c.get("/hello/world", [["Accept", "*/*"]]);
|
|
|
|
req.finish(function (res) {
|
2009-05-19 20:24:37 +02:00
|
|
|
puts("response 1: " + res.status_code.toString());
|
2009-05-19 13:12:46 +02:00
|
|
|
|
|
|
|
res.onBody = function (chunk) {
|
2009-05-19 20:24:37 +02:00
|
|
|
puts("response 1 body <" + chunk.encodeUtf8() + ">");
|
2009-05-19 13:12:46 +02:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
res.onBodyComplete = function () {
|
2009-05-19 20:24:37 +02:00
|
|
|
puts("response 1 complete!");
|
2009-05-19 13:12:46 +02:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
});
|
2009-05-19 20:24:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
*/
|