docs: function mockProxy(host, port) {
    // this state is GET or PUT on the http://localhost:8888/proxy url
    // a test framework is expected to PUT this value to correct proxy if needed
    var proxy = { host: host, port: port };
  
    // this state is GET, PUT, or DELETE on the http://localhost:8888/session url
    // a test framework is expected to PUT before and DELETE after each test
    // valid modes include 'neutral', 'recording', and 'playback'
    var session = { mode: 'neutral', name: '' };
  
    // this is the current driver, it's updated when the /session state is altered
    var driver = driverFactory.create(proxy, session);
  
    return function (request, response) {
      var u = url.parse(request.url, true);
      var isLocal = request.headers.host == 'localhost:8888' || u.host == 'localhost:8888';
      if (!isLocal) {
        driver.call(request, response);
        return;
      }
  
      writeLog("CONTROL: " + request.method + ' ' + u.pathname);
      response.setHeader('Content-Type', 'text/plain');
      if (u.pathname == '/') {
        response.setHeader('Content-Type', 'text/html');
        response.end(fs.readFileSync("index.html"));
      }
      else if (u.pathname == '/proxy') {
        if (request.method == "GET") {
          response.end(JSON.stringify(proxy));
        }
        else if (request.method == "PUT") {
          var data = '';
          request.on('data', function (chunk) {
            data += chunk;
          });
          request.on('end', function () {
            writeLog("  " + data);
            var put = JSON.parse(data);
            proxy.host = put.host;
            proxy.port = put.port;
            response.end();
          });
        }
        else {
          response.end();
        }
      }
      else if (u.pathname == '/session') {
        if (request.method == "GET") {
          response.end(JSON.stringify(session));
        }
        else if (request.method == "PUT") {
          var data = '';
          request.on('data', function (chunk) {
            data += chunk;
          });
          request.on('end', function () {
            writeLog("  " + data);
            var put = JSON.parse(data);
            session = { mode: put.mode, name: put.name };
            driver.close();
            driver = driverFactory.create(proxy, session);
            response.end();
          });
        }
        else if (request.method == "DELETE") {
          driver.close();
          session = { mode: 'neutral', name: '' };
          driver = driverFactory.create(proxy, session);
          response.end();
        }
        else {
          response.end();
        }
      }
      else if (u.pathname == '/sessions') {
        var sessions = fs.readdirSync(sessionsRootPath);
        response.setHeader('Content-Type', 'text/html');
        response.write('<ul>');
        for (k in sessions) {
          response.write('<li><a href="sessions/');
          response.write(sessions[k]);
          response.write('">');
          response.write(sessions[k]);
          response.write('</a></li>');
        }
        response.write('</ul>');
        response.end();
      }
      else if (u.pathname.indexOf('/sessions/') == 0) {
        var records = JSON.parse(fs.readFileSync('.' + u.pathname + '/index.json'));
        response.setHeader('Content-Type', 'text/html');
        response.write('<ul>');
        for (var k in records) {
          response.write('<li>');
          response.write(records[k].requestMethod);
          response.write(' ');
          response.write(records[k].requestUrl);
          response.write('</li>');
        }
  
        response.write('</ul>');
        response.end();
      }
      else {
        response.statusCode = 404;
        response.write('404 Huh?');
        response.end();
      }
    };
  }