Created
August 26, 2011 19:39
-
-
Save stonecobra/1174240 to your computer and use it in GitHub Desktop.
proxy sample
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 https = require('https'); | |
| function hardProxy(request, response) { | |
| var options = { | |
| host: config.server.dbOptions.host | |
| , method: request.method | |
| , path: request.params[0] | |
| , headers: getHeaders(request) | |
| } | |
| var req = https.request(options, function(res) { | |
| res.on('data', function(chunk) { | |
| response.write(chunk); | |
| }); | |
| }); | |
| req.on('error', function(e) { | |
| console.log('error in hardProxy: ' + e); | |
| }); | |
| request.on('data', function(chunk) { | |
| console.log('data: ' + chunk); | |
| response.write(chunk, 'binary'); | |
| }); | |
| request.on('end', function() { | |
| console.log('end: ' + chunk); | |
| req.end(); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment