Last active
July 23, 2018 20:15
-
-
Save leozc/4667579 to your computer and use it in GitHub Desktop.
Node.js HTTP sleep server
Simulate HTTP Timeout error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var sleep = require('sleep'); | |
var timeout = 100000; //sleep 100 seconds | |
http.createServer(function (req, res) { | |
setTimeout((function() { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end("Hello I am awake"); | |
}), timeout); | |
}).listen(8080); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! But I don't see any use of the
sleep
module. I've removed it and it still works fine.