Skip to content

Commit 30b0522

Browse files
committed
Bugfix: HTTP client automatically reconnecting
Test case by tlynn.
1 parent cd6397c commit 30b0522

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
process.mixin(require("./common"));
2+
3+
var tcp = require("tcp"),
4+
sys = require("sys"),
5+
http = require("http");
6+
7+
var PORT = 2143;
8+
9+
var errorCount = 0;
10+
var eofCount = 0;
11+
12+
var server = tcp.createServer(function(socket) {
13+
socket.close();
14+
});
15+
server.listen(PORT);
16+
17+
var client = http.createClient(PORT);
18+
19+
client.addListener("error", function() {
20+
sys.puts("ERROR!");
21+
errorCount++;
22+
});
23+
24+
client.addListener("eof", function() {
25+
sys.puts("EOF!");
26+
eofCount++;
27+
});
28+
29+
var request = client.request("GET", "/", {"host": "localhost"});
30+
request.finish(function(response) {
31+
sys.puts("STATUS: " + response.statusCode);
32+
});
33+
34+
setTimeout(function () {
35+
server.close();
36+
}, 500);
37+
38+
39+
process.addListener('exit', function () {
40+
assert.equal(0, errorCount);
41+
assert.equal(1, eofCount);
42+
});

0 commit comments

Comments
 (0)