add:  server.registerPathHandler("/redirect", redirect); 
context: function runServer(){  serverBasePath = Cc["@mozilla.org/file/local;1"]                     .createInstance(Ci.nsILocalFile);  var procDir = Cc["@mozilla.org/file/directory_service;1"]                  .getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile);  serverBasePath.initWithPath(procDir.parent.parent.path);  serverBasePath.append("_tests");  serverBasePath.append("testing");  serverBasePath.append("mochitest");  server = new nsHttpServer();  server.registerDirectory("/", serverBasePath);  if (environment["CLOSE_WHEN_DONE"])    server.registerPathHandler("/server/shutdown", serverShutdown);  server.setIndexHandler(defaultDirHandler);  server.start(SERVER_PORT);  // touch a file in the profile directory to indicate we're alive  var foStream = Cc["@mozilla.org/network/file-output-stream;1"]                   .createInstance(Ci.nsIFileOutputStream);  var serverAlive = Cc["@mozilla.org/file/local;1"]                      .createInstance(Ci.nsILocalFile);  serverAlive.initWithFile(serverBasePath);  serverAlive.append("mochitesttestingprofile");  // If we're running outside of the test harness, there might  // not be a test profile directory present  if (serverAlive.exists()) {    serverAlive.append("server_alive.txt");    foStream.init(serverAlive,                  0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate    data = "It's alive!";    foStream.write(data, data.length);    foStream.close();  }  makeTags();  //  // The following is threading magic to spin an event loop -- this has to  // happen manually in xpcshell for the server to actually work.  //  var thread = Cc["@mozilla.org/thread-manager;1"]                 .getService()                 .currentThread;  while (!server.isStopped())    thread.processNextEvent(true);  // Server stopped by /server/shutdown handler -- go through pending events  // and return.  // get rid of any pending requests  while (thread.hasPendingEvents())    thread.processNextEvent(true);}
meta: 10520	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/10520/7fbc754f7bbfd3b7fd075f22c45a991104cd4233/server.js/clean/testing/mochitest/server.js