Skip to content

Instantly share code, notes, and snippets.

@greenlikeorange
Created September 16, 2014 04:53
Show Gist options
  • Save greenlikeorange/1e1f19c1ee9c7572e0ab to your computer and use it in GitHub Desktop.
Save greenlikeorange/1e1f19c1ee9c7572e0ab to your computer and use it in GitHub Desktop.
Stream request
var http = require('http');
http.createServer(function(req, res) {
var proxy = http.createClient(80, 'http://server2.com')
var proxyRequest = proxy.request(request.method, request.url, request.headers);
proxyRequest.on('response', function (proxyResponse) {
proxyResponse.pipe(response);
});
request.pipe(proxyRequest);
}).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment