Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
curl bbs
var http = require('http');
var 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');
res.write('> ');
req.on('data', function (buf) {
res.write(buf);
res.write('> ');
});
req.on('end', function () {
res.end();
});
console.log(req.headers['user-agent']);
var iv = setInterval(function () {
res.write(buf0);
}, 100);
res.connection.on('end', function () {
clearInterval(iv);
});
});
server.listen(8000);
substack : http-bbs $ curl -sSNT. localhost:8000
Welcome to the Fun House
> beep
beep
> boop
boop
> ^C
substack : http-bbs $
@jfhbrook

This comment has been minimized.

Copy link

@jfhbrook jfhbrook commented Nov 6, 2011

I'm surprised I hadn't seen this before. Pretty awesome!

@TooTallNate

This comment has been minimized.

Copy link

@TooTallNate TooTallNate commented Mar 7, 2012

Very, very cool. Though it seems like there's no way to terminate the connection from the server-side. I mean, you can kill it, but the curl command stays open, waiting for user input.

Not a huge deal but I can see why more people haven't tried messing around with this stuff (and/or just use telnet :p ).

Sweet stuff @substack!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment