Skip to content

Instantly share code, notes, and snippets.

@coderarity
Forked from RobSpectre/proxy.js
Created April 14, 2012 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderarity/2387677 to your computer and use it in GitHub Desktop.
Save coderarity/2387677 to your computer and use it in GitHub Desktop.
Proxy with buffering
var http = require('http'),
https = require('https'),
httpProxy = require('./lib/node-http-proxy');
var server = httpProxy.createServer({
target: { host: 'graph.facebook.com', port: 443, https: true },
changeOrigin: true },
function (req, res, proxy) {
console.log("Received request.");
server.proxy.response_buffer = '';
proxy.proxyRequest(req, res);
});
server.proxy.on('data', function(data) {
server.proxy.response_buffer += data;
});
server.proxy.on('end', function() {
console.log(server.proxy.response_buffer.toString());
});
server.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment