Created
April 10, 2015 00:29
-
-
Save billautomata/ad15b5a1a3ee53a1faf1 to your computer and use it in GitHub Desktop.
http replay
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'); | |
http.createServer(function (req, resp) { | |
var h = req.headers; | |
h.host = "stackoverflow.com"; | |
var req2 = http.request({ | |
host: h.host, port: 80, path: req.url, method: req.method, headers: h | |
}, function (resp2) { | |
resp.writeHead(resp2.statusCode, resp2.headers); | |
resp2.on('data', function (d) { resp.write(d); }); | |
resp2.on('end', function () { resp.end(); }); | |
}); | |
req.on('data', function (d) { req2.write(d); }); | |
req.on('end', function () { req2.end(); }); | |
}).listen(1337, "127.0.0.1"); | |
console.log('Server running at http://127.0.0.1:1337/ echoing '+h.host); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment