var persistence = require('../metrics/persistence.js'),
    countries = require('../lib/countries').countries,
    geoip = require('geoip-lite');

// GET /track/:script/:app_id
exports.impression = function(req, res) {
  var javascriptEnabled,
      appId = req.params.app_id,
      firstVisit = true,
      country = null;

  res.set("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
  res.set("Pragma", "no-cache"); // HTTP 1.0.
  res.set("Expires", 0); // Proxies.

  // if appID suffixed with another path such as /example, add to appId
  if (req.params[0]) { appId += req.params[0]; }

  switch (req.params.script) {
    case 'js':
      javascriptEnabled = true;
      break;
    case 'no-js':
      javascriptEnabled = false;
      break;
    default:
      res.set('Content-Type', 'text/plain');
      res.send(400, 'Invalid URL - expected js/no-js after /track/');
      return;
  };

  if (!req.params.app_id) {
    res.set('Content-Type', 'text/plain');
    res.send(400, 'Invalid URL - expected application ID after /track/' + req.params.script + '/');
    return;
  }

  var persistAndRespond = function() {
    persistence.save(appId, javascriptEnabled, firstVisit, country);
    res.set('Content-Type', 'image/gif');
    res.sendfile('public/images/blank.gif');
  };

  if (req.session.subsequentVisit) {
    firstVisit = false;
    if (countries[req.session.country]) {
      country = req.session.country;
    }
    persistAndRespond();
  } else {
    req.session.subsequentVisit = true;
    var geo = geoip.lookup(req.ip);
    if (geo && countries[geo.country]) {
      country = geo.country;
      req.session.country = country; // prevent further GeoIP lookups for this session
    }
    // country = ['US','FR','GB'][Math.floor(Math.random()*3)];
    // console.log('Simulating country ' + country);
    persistAndRespond();
  }
};
@@ -1723,16 +1723,22 @@
 %7D%0A    //
+ allow
  country
@@ -1742,63 +1742,218 @@
 try 
-= %5B'US','FR','GB'%5D%5BMath.floor(Math.random()*3)%5D
+to be injected for CURL tests%0A    if ( (req.host == 'localhost') %7C%7C (req.host == '127.0.0.1') ) %7B%0A      if (req.query.country) %7B%0A        country = req.query.country;%0A        req.session.param = country
 ;%0A    
-//
+   
  con
@@ -1961,45 +1961,81 @@
 ole.
-log('Simulating country ' + country);
+warn('Warn: Country for debugging assigned as ' + country);%0A      %7D%0A    %7D
 %0A   

Allow country to be specified when running locally