From 18dc9ef6f37dd84e7d4d4200777a8d57a7c1d47c Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Fri, 13 Jan 2012 15:56:10 -0700
Subject: [PATCH] always run our little node HTTP proxy locally to constantly
 test HTTP proxy support which we'll have in production - issue #904

---
 bin/proxy              | 2 +-
 lib/http_forward.js    | 1 +
 lib/primary.js         | 2 +-
 scripts/run_locally.js | 7 +++++++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bin/proxy b/bin/proxy
index abb513380..68a0f65d5 100755
--- a/bin/proxy
+++ b/bin/proxy
@@ -33,5 +33,5 @@ var server = http.createServer(function (req, res) {
   });
 }).listen(port, addy, function () {
   var a = server.address();
-  console.log("lil' HTTP proxy running: http://" + a.address + ":" + a.port);
+  console.log("running on http://" + a.address + ":" + a.port);
 });
diff --git a/lib/http_forward.js b/lib/http_forward.js
index 16b757703..59df8952d 100644
--- a/lib/http_forward.js
+++ b/lib/http_forward.js
@@ -25,6 +25,7 @@ module.exports = function(dest, req, res, cb) {
     method: req.method,
     agent: false
   }, function(pres) {
+
     res.statusCode = pres.statusCode;
     // forward along Content-Type and Content-Length, if available
     if (pres.headers.hasOwnProperty('content-type')) {
diff --git a/lib/primary.js b/lib/primary.js
index cefa8edaf..67f5d52cf 100644
--- a/lib/primary.js
+++ b/lib/primary.js
@@ -193,7 +193,7 @@ if (process.env['SHIMMED_PRIMARIES']) {
       publicKey: r.publicKey
     };
 
-    winston.info("inserted primary info for '" + domain + "' into cache, pointed at '" + origin + "'");
+    logger.info("inserted primary info for '" + domain + "' into cache, pointed at '" + origin + "'");
   });
 }
 
diff --git a/scripts/run_locally.js b/scripts/run_locally.js
index e7da1212a..41092e3d8 100755
--- a/scripts/run_locally.js
+++ b/scripts/run_locally.js
@@ -39,12 +39,19 @@ var daemonsToRun = {
     PORT: 10005,
     HOST: HOST
   },
+  proxy: {
+    PORT: 10006,
+    HOST: HOST
+  },
   browserid: {
     PORT: 10002,
     HOST: HOST
   }
 };
 
+// route outbound HTTP through our in-tree proxy to always test said codepath
+process.env['HTTP_PROXY'] = HOST + ":10006"; 
+
 // all spawned process that use handle primaries should know about "shimmed"
 // primaries
 process.env['SHIMMED_PRIMARIES'] = "example.domain|http://" + HOST + ":10005|" + path.join(__dirname, "..", "example", "primary", ".well-known", "browserid");
-- 
GitLab