|
|
@ -10,6 +10,7 @@ var chargen = http.createServer(function (req, res) { |
|
|
|
var len = req.headers['x-len']; |
|
|
|
res.writeHead(200, {"transfer-encoding":"chunked"}); |
|
|
|
for (var i=0; i<len; i++) { |
|
|
|
print(','); |
|
|
|
res.write(chunk); |
|
|
|
} |
|
|
|
res.end(); |
|
|
@ -18,11 +19,12 @@ chargen.listen(9000); |
|
|
|
|
|
|
|
// Proxy to the chargen server.
|
|
|
|
var proxy = http.createServer(function (req, res) { |
|
|
|
var proxy_req = http.createClient(9000, 'localhost') |
|
|
|
.request(req.method, req.url, req.headers); |
|
|
|
var c = http.createClient(9000, 'localhost') |
|
|
|
var proxy_req = c.request(req.method, req.url, req.headers); |
|
|
|
proxy_req.addListener('response', function(proxy_res) { |
|
|
|
res.writeHead(proxy_res.statusCode, proxy_res.headers); |
|
|
|
proxy_res.addListener('data', function(chunk) { |
|
|
|
print('.'); |
|
|
|
res.write(chunk); |
|
|
|
}); |
|
|
|
proxy_res.addListener('end', function() { |
|
|
@ -47,8 +49,7 @@ function call_chargen(list) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
req.end(); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
sys.puts("End of list."); |
|
|
|
proxy.end(); |
|
|
|
chargen.end(); |
|
|
|