108036fbc3e61b752144a35b1adf899f3ee262d3
larrym
  Mon Mar 21 16:39:47 2011 -0700
make hHostHasPrefix work when CGIs are run from the command line
diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 9e56d76..d5aa689 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3033,30 +3033,33 @@
 hash = tableListGetDbHash(db);
 hel = hashLookup(hash, rootName);
 if (hel == NULL)
     return NULL;
 else
     return slNameCloneList((struct slName *)(hel->val));
 }
 
 boolean hHostHasPrefix(char *prefix)
 /* Return TRUE if this is running on web-server with host name prefix */
 {
 if (prefix == NULL)
     return FALSE;
 
 char *httpHost = getenv("HTTP_HOST");
+if (httpHost == NULL)
+    // make sure this works when CGIs are run from the command line.
+    httpHost = getenv("HOST");
 
 if (httpHost == NULL)
     return FALSE;
 
 return startsWith(prefix, httpHost);
 }
 
 boolean hIsPrivateHost()
 /* Return TRUE if this is running on private (development) web-server.
  * This was originally genome-test as well as hgwdev, however genome-test
  * may be repurposed to direct users to the preview site instead of development site. */
 {
 return hHostHasPrefix("hgwdev") || hHostHasPrefix("genome-test");  // FIXME: If genome-test
 }