Skip to content

Instantly share code, notes, and snippets.

@FLYBYME
Last active December 14, 2015 06:49
Show Gist options
  • Save FLYBYME/5045528 to your computer and use it in GitHub Desktop.
Save FLYBYME/5045528 to your computer and use it in GitHub Desktop.
var bouncy = require('bouncy');
var http = require('http');
var net = require('net');
function connect(cb) {
var options = {
hostname : 'localhost',
port : 8000,
path : '/',
method : 'GET'
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
cb()
});
req.end();
}
bouncy(function(req, res, bounce) {
console.log('bouncy request')
bounce(net.connect({
port : 8001,
host : 'localhost'
}), {
headers : {
"x-test-bounce" : 'pass'
}
});
}).listen(8000, function() {
connect(function() {
connect(function() {
})
})
});
http.createServer(function(req, res) {
console.log('server request', req.headers)
res.writeHeader(200, {
"x-test" : 'pass'
})
res.write(JSON.stringify(req.headers, null, 4))
res.end('beep boop\n');
}).listen(8001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment