Created
June 5, 2014 18:40
-
-
Save richorama/28cfbd5add58dc0eea02 to your computer and use it in GitHub Desktop.
An HTTP proxy server written in Node.js
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 http = require('http'); | |
var url = require('url'); | |
http.createServer(function(request, response) { | |
console.log(request.url); | |
var options = url.parse(request.url); | |
options.method = request.method; | |
options.headers = request.headers; | |
var req = http.request(options, function(res){ | |
response.writeHead(res.statusCode, res.headers); | |
res.pipe(response); | |
}) | |
request.pipe(req); | |
}).listen(process.env.port || 8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment