Skip to content

Instantly share code, notes, and snippets.

@tvandervossen
Last active December 28, 2015 10:49
Show Gist options
  • Select an option

  • Save tvandervossen/7489079 to your computer and use it in GitHub Desktop.

Select an option

Save tvandervossen/7489079 to your computer and use it in GitHub Desktop.
Quick node.js script to help you test your fancy client-side XHR2 progress bar implementation.
var http = require('http')
var sleep = require('sleep')
var server = http.createServer(function (req, res) {
// console.log(req.headers);
req.on('data', function(chunk) {
console.log('chunk: %d bytes', chunk.length)
// console.log(chunk.toString('utf8'))
sleep.sleep(1)
})
req.on('end', function () {
res.writeHead(200, {'Content-Type': 'text/plain', 'Access-Control-Allow-Origin': '*'})
res.end('Done, thanks.\n')
})
})
server.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment