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