Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created March 22, 2013 12:38
Show Gist options
  • Save apaleslimghost/5220944 to your computer and use it in GitHub Desktop.
Save apaleslimghost/5220944 to your computer and use it in GitHub Desktop.
an import.io backend proxy that sometimes takes 51 seconds to respond
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