From 30b0522157069360615402651d6b98c9397dfc19 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 27 Jan 2010 09:34:45 -0800 Subject: [PATCH] Bugfix: HTTP client automatically reconnecting Test case by tlynn. --- test/mjsunit/test-http-client-reconnect-bug.js | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/mjsunit/test-http-client-reconnect-bug.js diff --git a/test/mjsunit/test-http-client-reconnect-bug.js b/test/mjsunit/test-http-client-reconnect-bug.js new file mode 100644 index 0000000..16a63f9 --- /dev/null +++ b/test/mjsunit/test-http-client-reconnect-bug.js @@ -0,0 +1,42 @@ +process.mixin(require("./common")); + +var tcp = require("tcp"), + sys = require("sys"), + http = require("http"); + +var PORT = 2143; + +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("eof", function() { + sys.puts("EOF!"); + eofCount++; +}); + +var request = client.request("GET", "/", {"host": "localhost"}); +request.finish(function(response) { + sys.puts("STATUS: " + response.statusCode); +}); + +setTimeout(function () { + server.close(); +}, 500); + + +process.addListener('exit', function () { + assert.equal(0, errorCount); + assert.equal(1, eofCount); +}); -- 2.7.4