mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
798 B
42 lines
798 B
15 years ago
|
process.mixin(require("../common"));
|
||
15 years ago
|
|
||
|
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++;
|
||
|
});
|
||
|
|
||
15 years ago
|
client.addListener("end", function() {
|
||
15 years ago
|
sys.puts("EOF!");
|
||
|
eofCount++;
|
||
|
});
|
||
|
|
||
|
var request = client.request("GET", "/", {"host": "localhost"});
|
||
15 years ago
|
request.addListener('response', function(response) {
|
||
15 years ago
|
sys.puts("STATUS: " + response.statusCode);
|
||
|
});
|
||
15 years ago
|
request.close();
|
||
15 years ago
|
|
||
|
setTimeout(function () {
|
||
|
server.close();
|
||
|
}, 500);
|
||
|
|
||
|
|
||
|
process.addListener('exit', function () {
|
||
|
assert.equal(0, errorCount);
|
||
|
assert.equal(1, eofCount);
|
||
|
});
|