Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Node.js HTTP streaming example (Event connection close doesn't work on heroku).
{
"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"
}
}
web: node web.js
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.