cloudhead / node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
MIT License
2.17k stars 245 forks source link

setTimeout not working? Can't throttle server... #220

Open mellis481 opened 3 years ago

mellis481 commented 3 years ago

I'd essentially like to create a throttled server. I thought I could do something like this:

require('http').createServer(function (request, response) {
  request.addListener('end', function () {
    setTimeout(function () { fileServer.serve(request, response); }, 2000);
  }).resume();
}).listen(8080);

As you can see, I've wrapped my server() call in a setTimeout. This doesn't seem to be working, though.

How can I throttle my server?