Skip to content

Instantly share code, notes, and snippets.

@Jabher
Created August 7, 2015 10:48
Show Gist options
  • Save Jabher/22a1ee55c6409a72eb32 to your computer and use it in GitHub Desktop.
Save Jabher/22a1ee55c6409a72eb32 to your computer and use it in GitHub Desktop.
import {Server} from 'http';
const server = new Server();
server.listen(8080);
server.on('request', async function (req, res) {
req.pause();
res.statusCode = 200;
req.on('end', () => res.end('OK'));
const length = message.headers['content-length'];
const chunk = length / 100;
for (let i = 0; i < length; i++) {
await new Promise(res => setTimeout(res, 250));
req.read(chunk);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment