Last active
December 14, 2015 06:49
-
-
Save FLYBYME/5045528 to your computer and use it in GitHub Desktop.
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
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