0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/pummel/test-http-client-reconnect-bug.js

42 lines
798 B
JavaScript
Raw Normal View History

2010-02-25 07:36:17 +01:00
process.mixin(require("../common"));
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++;
});
client.addListener("end", function() {
sys.puts("EOF!");
eofCount++;
});
var request = client.request("GET", "/", {"host": "localhost"});
request.addListener('response', function(response) {
sys.puts("STATUS: " + response.statusCode);
});
request.close();
setTimeout(function () {
server.close();
}, 500);
process.addListener('exit', function () {
assert.equal(0, errorCount);
assert.equal(1, eofCount);
});