2010-02-25 07:36:17 +01:00
|
|
|
process.mixin(require("../common"));
|
2010-01-27 18:34:45 +01:00
|
|
|
|
|
|
|
var tcp = require("tcp"),
|
|
|
|
sys = require("sys"),
|
|
|
|
http = require("http");
|
|
|
|
|
|
|
|
var errorCount = 0;
|
|
|
|
var eofCount = 0;
|
|
|
|
|
|
|
|
var server = tcp.createServer(function(socket) {
|
|
|
|
socket.close();
|
|
|
|
});
|
|
|
|
server.listen(PORT);
|
|
|
|
|
|
|
|
var client = http.createClient(PORT);
|
|
|
|
|
|
|
|
client.addListener("error", function() {
|
|
|
|
sys.puts("ERROR!");
|
|
|
|
errorCount++;
|
|
|
|
});
|
|
|
|
|
2010-02-12 09:25:15 +01:00
|
|
|
client.addListener("end", function() {
|
2010-01-27 18:34:45 +01:00
|
|
|
sys.puts("EOF!");
|
|
|
|
eofCount++;
|
|
|
|
});
|
|
|
|
|
|
|
|
var request = client.request("GET", "/", {"host": "localhost"});
|
2010-02-17 20:10:10 +01:00
|
|
|
request.addListener('response', function(response) {
|
2010-01-27 18:34:45 +01:00
|
|
|
sys.puts("STATUS: " + response.statusCode);
|
|
|
|
});
|
2010-02-17 20:10:10 +01:00
|
|
|
request.close();
|
2010-01-27 18:34:45 +01:00
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
server.close();
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
|
|
process.addListener('exit', function () {
|
|
|
|
assert.equal(0, errorCount);
|
|
|
|
assert.equal(1, eofCount);
|
|
|
|
});
|