2010-07-15 11:47:25 -07:00
|
|
|
common = require("../common");
|
|
|
|
assert = common.assert;
|
|
|
|
http = require('http');
|
2010-05-12 10:01:27 -07:00
|
|
|
|
|
|
|
server = http.createServer(function (req, res) {
|
2010-06-23 17:40:51 -07:00
|
|
|
console.log('got request. setting 1 second timeout');
|
2010-05-12 10:01:27 -07:00
|
|
|
req.connection.setTimeout(500);
|
|
|
|
|
|
|
|
req.connection.addListener('timeout', function(){
|
2010-07-15 11:47:25 -07:00
|
|
|
common.debug("TIMEOUT");
|
2010-05-12 10:01:27 -07:00
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-07-15 11:47:25 -07:00
|
|
|
server.listen(common.PORT, function () {
|
|
|
|
console.log('Server running at http://127.0.0.1:'+common.PORT+'/');
|
2010-05-12 10:01:27 -07:00
|
|
|
|
2010-07-15 11:47:25 -07:00
|
|
|
errorTimer = setTimeout(function () {
|
2010-05-12 10:01:27 -07:00
|
|
|
throw new Error('Timeout was not sucessful');
|
|
|
|
}, 2000);
|
|
|
|
|
2010-07-15 11:47:25 -07:00
|
|
|
http.cat('http://localhost:'+common.PORT+'/', 'utf8', function (err, content) {
|
2010-05-12 10:01:27 -07:00
|
|
|
clearTimeout(errorTimer);
|
2010-06-23 17:40:51 -07:00
|
|
|
console.log('HTTP REQUEST COMPLETE (this is good)');
|
2010-05-12 10:01:27 -07:00
|
|
|
});
|
|
|
|
});
|