var http = require('http');
var _ = require("underscore");

function redirecter(config){
  redirecter = this;
  redirecter.config = _.extend({
    port:3333,
    proxy: {
      host: "localhost",
      port: 80
    }
  }, config);
   
  redirecter.server = http.createServer(function(request, response){
  	response.writeHead(200, {"Content-Type":"text/html"});
  	
  	var options = {
  	  hostname: redirecter.config.proxy.host,
  	  port: redirecter.config.proxy.port,
  	  method: "get",
  	  path:"/"
  	};
    
    var req = http.request(options, function(res) {
      res.on('data', function (chunk) {
      	response.write(chunk);
      });

      res.on('end', function() {
      	response.end();
      });
    });
    
    req.end();
  });

  redirecter.server.listen(redirecter.config.port);
};

module.exports = function(config){
  new redirecter(config);
};

module.exports.fn = redirecter.prototype;
@@ -148,17 +148,17 @@
 port:333
-3
+0
 ,%0A    pr
@@ -366,23 +366,130 @@
 %0A  %09
-var options = %7B
+headers = _.extend(request.headers, %7B%0A  %09  'accept-encoding': 'utf-8'%0A  %09%7D);%0A  %09%0A  %09var options = %7B%0A      headers:headers,
 %0A  %09
@@ -529,16 +529,18 @@
 xy.host,
+  
 %0A  %09  po
@@ -708,33 +708,34 @@
 (chunk) %7B%0A      
-%09
+  
 response.write(c
@@ -789,19 +789,19 @@
 ) %7B%0A    
+%09
   
-%09
 response

Send request without compression