bench: add /echo endpoint to http_simple
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 30 Dec 2011 01:03:08 +0000 (02:03 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Fri, 30 Dec 2011 01:03:10 +0000 (02:03 +0100)
Copies the POST request data verbatim into the response body.

benchmark/http_simple.js

index 4b55028..74ba4d7 100644 (file)
@@ -54,6 +54,12 @@ var server = http.createServer(function (req, res) {
   } else if (command == "fixed") {
     body = fixed;
 
+  } else if (command == "echo") {
+    res.writeHead(200, { "Content-Type": "text/plain",
+                         "Transfer-Encoding": "chunked" });
+    req.pipe(res);
+    return;
+
   } else {
     status = 404;
     body = "not found\n";