|
|
@ -29,19 +29,20 @@ var server = http.createServer(function (req, res) { |
|
|
|
}); |
|
|
|
server.listen(common.PORT); |
|
|
|
|
|
|
|
var client = http.createClient(common.PORT); |
|
|
|
|
|
|
|
var body1 = ""; |
|
|
|
var body2 = ""; |
|
|
|
var body3 = ""; |
|
|
|
|
|
|
|
//
|
|
|
|
// Client #1 is assigned Parser #1
|
|
|
|
//
|
|
|
|
var req1 = client.request("/1") |
|
|
|
req1.end(); |
|
|
|
req1.addListener('response', function (res1) { |
|
|
|
res1.setBodyEncoding("utf8"); |
|
|
|
server.addListener("listening", function() { |
|
|
|
var client = http.createClient(common.PORT); |
|
|
|
|
|
|
|
//
|
|
|
|
// Client #1 is assigned Parser #1
|
|
|
|
//
|
|
|
|
var req1 = client.request("/1") |
|
|
|
req1.end(); |
|
|
|
req1.addListener('response', function (res1) { |
|
|
|
res1.setEncoding("utf8"); |
|
|
|
|
|
|
|
res1.addListener('data', function (chunk) { |
|
|
|
body1 += chunk; |
|
|
@ -67,7 +68,7 @@ req1.addListener('response', function (res1) { |
|
|
|
var req2 = client.request("/2"); |
|
|
|
req2.end(); |
|
|
|
req2.addListener('response', function (res2) { |
|
|
|
res2.setBodyEncoding("utf8"); |
|
|
|
res2.setEncoding("utf8"); |
|
|
|
res2.addListener('data', function (chunk) { body2 += chunk; }); |
|
|
|
res2.addListener('end', function () { |
|
|
|
|
|
|
@ -78,7 +79,7 @@ req1.addListener('response', function (res1) { |
|
|
|
var req3 = client2.request("/3"); |
|
|
|
req3.end(); |
|
|
|
req3.addListener('response', function (res3) { |
|
|
|
res3.setBodyEncoding("utf8"); |
|
|
|
res3.setEncoding("utf8"); |
|
|
|
res3.addListener('data', function (chunk) { body3 += chunk }); |
|
|
|
res3.addListener('end', function() { server.close(); }); |
|
|
|
}); |
|
|
@ -86,6 +87,7 @@ req1.addListener('response', function (res1) { |
|
|
|
}); |
|
|
|
}, 500); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
process.addListener("exit", function () { |
|
|
|