2010-03-09 00:06:29 +01:00
|
|
|
require("../common");
|
2009-10-31 19:02:30 +01:00
|
|
|
http = require("http");
|
2009-06-17 08:01:28 +02:00
|
|
|
|
|
|
|
var body = "exports.A = function() { return 'A';}";
|
2009-09-28 12:36:36 +02:00
|
|
|
var server = http.createServer(function (req, res) {
|
2009-08-13 13:47:16 +02:00
|
|
|
puts("got request");
|
2010-02-25 21:54:48 +01:00
|
|
|
res.writeHead(200, [
|
2009-06-17 08:01:28 +02:00
|
|
|
["Content-Length", body.length],
|
|
|
|
["Content-Type", "text/plain"]
|
|
|
|
]);
|
2010-04-08 19:44:22 +02:00
|
|
|
res.end(body);
|
2009-06-17 08:52:47 +02:00
|
|
|
});
|
|
|
|
server.listen(PORT);
|
2009-06-17 08:01:28 +02:00
|
|
|
|
2009-06-28 19:05:58 +02:00
|
|
|
var got_good_server_content = false;
|
|
|
|
var bad_server_got_error = false;
|
|
|
|
|
2010-04-05 20:32:18 +02:00
|
|
|
server.addListener('listening', function () {
|
|
|
|
http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) {
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
} else {
|
|
|
|
puts("got response");
|
|
|
|
got_good_server_content = true;
|
|
|
|
assert.equal(body, content);
|
|
|
|
server.close();
|
|
|
|
}
|
|
|
|
});
|
2009-08-26 18:22:00 +02:00
|
|
|
|
2010-04-05 20:32:18 +02:00
|
|
|
http.cat("http://localhost:12312/", "utf8", function (err, content) {
|
|
|
|
if (err) {
|
|
|
|
puts("got error (this should happen)");
|
|
|
|
bad_server_got_error = true;
|
|
|
|
}
|
|
|
|
});
|
2009-08-26 18:22:00 +02:00
|
|
|
});
|
2009-06-21 16:59:11 +02:00
|
|
|
|
2009-08-26 18:51:04 +02:00
|
|
|
process.addListener("exit", function () {
|
2009-09-28 12:36:36 +02:00
|
|
|
puts("exit");
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, got_good_server_content);
|
|
|
|
assert.equal(true, bad_server_got_error);
|
2009-08-26 18:51:04 +02:00
|
|
|
});
|