Clean up tests. Add docs.
authorRyan <ry@tinyclouds.org>
Tue, 19 May 2009 20:32:41 +0000 (22:32 +0200)
committerRyan <ry@tinyclouds.org>
Tue, 19 May 2009 20:32:41 +0000 (22:32 +0200)
test/test-http-server.js [moved from test/test-http.js with 98% similarity]
test_client.js
website/node.html

similarity index 98%
rename from test/test-http.js
rename to test/test-http-server.js
index c8e05bb..59300cf 100644 (file)
@@ -1,6 +1,6 @@
 include("mjsunit");
 
-var port = 8000;
+var port = 8222;
 
 function onLoad() {
 
index 56fe6ac..ddd1d48 100644 (file)
@@ -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;
-  };
-});
-*/
index 488f864..2226393 100644 (file)
@@ -225,10 +225,14 @@ See <a
 <h3 id="http"><code>node.http</code></h3>
 
 <p> Node provides a web server and client interface. The interface is rather
-low-level but complete. For example, it does not parse
-<code class="sh_javascript">application/x-www-form-urlencoded</code> message bodies. The interface
-does abstract the Transfer-Encoding (i.e. chuncked or identity), Message
-boundaries, and Keep-Alive connections. 
+low-level but complete. (By complete, I mean that it does not limit you from
+any of HTTP's features.) The interface abstracts the Transfer-Encoding (i.e.
+chuncked or identity), message boundaries, and persistent connections.
+Message header and body parsing needs to be done in high-level abstractions.
+
+<p> There are even lower level versions of both the server and client. You
+very likely do not need the level of granuality provided by them. There are
+no docs for those interfaces.
 
 <h4 id="http_server"><code class="sh_javascript">node.http.Server</code></h4>