Skip to content

Instantly share code, notes, and snippets.

@stonecobra
Created August 26, 2011 19:39
Show Gist options
  • Select an option

  • Save stonecobra/1174240 to your computer and use it in GitHub Desktop.

Select an option

Save stonecobra/1174240 to your computer and use it in GitHub Desktop.
proxy sample
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