diff options
author | Ryan <ry@tinyclouds.org> | 2009-05-20 00:32:41 +0400 |
---|---|---|
committer | Ryan <ry@tinyclouds.org> | 2009-05-20 00:32:41 +0400 |
commit | 5e37dfca0251f8932b510c3a8bb3cb0aca58243c (patch) | |
tree | 41e3714b4902f3e464bb1165053b637ed5cb567e /test_client.js | |
parent | 82e773630b38f4a5c0ec6eaf18c361fbe687fc15 (diff) |
Clean up tests. Add docs.
Diffstat (limited to 'test_client.js')
-rw-r--r-- | test_client.js | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/test_client.js b/test_client.js index 56fe6acf944..ddd1d486004 100644 --- a/test_client.js +++ b/test_client.js @@ -1,11 +1,12 @@ var c = new node.http.Client(8000, "localhost") -var req = c.get("/hello/world", [["Accept", "*/*"]]); +var req = c.get("/bytes/123", [["Accept", "*/*"]]); req.finish(function (res) { puts("response 1: " + res.status_code.toString()); res.onBody = function (chunk) { - puts("response 1 body <" + chunk.encodeUtf8() + ">"); + chunk = chunk.encodeUtf8(); + puts("response 1 body <" + JSON.stringify(chunk) + ">"); return true; }; @@ -15,19 +16,21 @@ req.finish(function (res) { }; }); -/* -var req = c.get("/something/else", []); -req.finish(function (res) { - puts("response 2: " + res.status_code.toString()); +setTimeout(function () { + var req2 = c.get("/something/else", []); + req2.finish(function (res) { + puts("response 2: " + res.status_code.toString()); - res.onBody = function (chunk) { - puts("response 2 body <" + chunk.encodeUtf8() + ">"); - return true; - }; + res.onBody = function (chunk) { + chunk = chunk.encodeUtf8(); + puts("response 2 body <" + JSON.stringify(chunk) + ">"); + return true; + }; + + res.onBodyComplete = function () { + puts("response 2 complete!"); + return true; + }; + }); +}, 2000); - res.onBodyComplete = function () { - puts("response 2 complete!"); - return true; - }; -}); -*/ |