Last active
May 17, 2018 18:53
-
-
Save sampaiodiego/f8e11189aa952c29373d8ebddcf13f6d to your computer and use it in GitHub Desktop.
proxy.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
const http = require('http'); | |
const https = require('https'); | |
const proxy = http.createServer().listen(3128); | |
proxy.on('request', (request, response) => { | |
console.log('request ->',request.method); | |
const options = { | |
hostname: 'www.google.com', | |
port: 443, | |
path: request.url, | |
method: request.method | |
}; | |
const req = https.request(options, (req) => { | |
response.writeHead(req.statusCode, req.headers); | |
return req.pipe(response, {end: true}); | |
}); | |
request.pipe(req, {end: true}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment