1 path = require("path");
3 port = parseInt(process.env.PORT || 8000);
5 var puts = require("sys").puts;
7 var old = (process.argv[2] == 'old');
9 puts('pid ' + process.pid);
11 http = require(old ? "http_old" : 'http');
12 if (old) puts('old version');
15 for (var i = 0; i < 20*1024; i++) {
21 http.createServer(function (req, res) {
22 var commands = req.url.split("/");
23 var command = commands[1];
25 var arg = commands[2];
28 if (command == "bytes") {
29 var n = parseInt(arg, 10)
31 throw "bytes called with n <= 0"
32 if (stored[n] === undefined) {
33 puts("create stored[n]");
35 for (var i = 0; i < n; i++) {
41 } else if (command == "quit") {
42 res.connection.server.close();
45 } else if (command == "fixed") {
53 var content_length = body.length.toString();
56 , { "Content-Type": "text/plain"
57 , "Content-Length": content_length
61 res.write(body, 'ascii');
64 res.end(body, 'ascii');
68 puts('Listening at http://127.0.0.1:'+port+'/');