0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/pummel/test-http-client-reconnect-bug.js
Ryan Dahl ba792ea202 :%s/sys.puts/console.log/g
and there was much rejoicing
2010-06-23 20:05:29 -07:00

42 lines
788 B
JavaScript

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.end();
});
server.listen(PORT);
var client = http.createClient(PORT);
client.addListener("error", function() {
console.log("ERROR!");
errorCount++;
});
client.addListener("end", function() {
console.log("EOF!");
eofCount++;
});
var request = client.request("GET", "/", {"host": "localhost"});
request.end();
request.addListener('response', function(response) {
console.log("STATUS: " + response.statusCode);
});
setTimeout(function () {
server.close();
}, 500);
process.addListener('exit', function () {
assert.equal(0, errorCount);
assert.equal(1, eofCount);
});