Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Node.js HTTP streaming example (Event connection close doesn't work on heroku).

View Procfile
1 2 3 4 5 6 7 8 9 10 11 12 13
{
"name": "node-example",
"version": "0.0.1",
"dependencies": {
"express": "3.1.x",
"mongodb" : "1.1.11",
"redis-url": "0.1.0"
},
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
}
}
View Procfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
var express = require("express");
var app = express();
app.use(express.logger());
 
app.get('/', function(req, res) {
 
res.writeHead(200, {'Content-type': 'text/javascript'});
 
req.connection.on('close',function(){
// code to handle connection abort
console.log("closed connection");
clearInterval(interval);
res.end();
});
 
var interval = setInterval(function(){
res.write('Body data.\n');
console.log("Still processing a response.");
}, 1000);
});
 
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.