ExpressJS: How to know when a request has finished?
req.on("close")
So simply
app.get('/keys/readresults/:keyname', basic_auth, function(req,res){
res.writeHead(200, {'content-type': 'text/json'});
var no = setInterval(
go_to_database_and_get('stuff', function (database_replies) {
res.write(database_replies)
});
,5000);
req.on("close", function() {
clearInterval(no);
});
});
req.on('close', ...)
no longer works in Express 4. Use the on-finished
middleware.