Skip to content

Instantly share code, notes, and snippets.

@watson
Created June 4, 2014 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watson/439478eea653aa1cba72 to your computer and use it in GitHub Desktop.
Save watson/439478eea653aa1cba72 to your computer and use it in GitHub Desktop.
Trying to auto-resume a paused stream by piping (not working)
var http = require('http');
http.createServer(function (req, res) {
console.log('Got request');
req.pause();
var size = 0;
req.on('data', function (chunk) {
console.log('Counting...');
size += chunk.length;
});
req.on('end', function () {
console.log('Size of request:', size);
});
console.log('Piping...');
req.pipe(res);
}).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment