Created
March 22, 2013 12:38
-
-
Save apaleslimghost/5220944 to your computer and use it in GitHub Desktop.
an import.io backend proxy that sometimes takes 51 seconds to respond
This file contains 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
http = require \http | |
http.create-server (req,res)-> | |
opts = { | |
host: "api.import.io" | |
port: 80 | |
req.method | |
path: req.url | |
req.headers | |
} | |
req.pipe http.request opts, (response)-> | |
send-resp = -> | |
res.write-head response.status-code, response.headers | |
response.pipe res | |
if Math.random! < 0.3 | |
console.log "timing you out lol" | |
set-timeout send-resp, 51000ms | |
else send-resp! | |
.listen 8001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment