Created
February 27, 2013 22:10
-
-
Save blakmatrix/5052275 to your computer and use it in GitHub Desktop.
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'), | |
repl = require('repl'), | |
buf0 = new Buffer([0]); | |
var server = http.createServer(function (req, res) { | |
res.setHeader('content-type', 'multipart/octet-stream'); | |
res.write('Welcome to the Fun House\r\n'); | |
repl.start({ | |
prompt: 'curl repl> ' | |
, input: req | |
, output: res | |
, terminal: false | |
, useColors: true | |
, useGlobal: false | |
}); | |
// log | |
console.log(req.headers['user-agent']); | |
// hack to thread stdin and stdout | |
// simultaneously in curl's single thread | |
var iv = setInterval(function () { | |
res.write(buf0); | |
}, 100); | |
res.connection.on('end', function () { | |
clearInterval(iv); | |
}); | |
}); | |
server.listen(8000);% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment