183a7505b5251fb0bdc4a6fca6d6420ed6a8d4b7 hiram Wed May 1 14:46:21 2019 -0700 add hg.conf variable to turn on the html output on the URL /cgi-bin/hubApi refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 8933c99..afeb9cc 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -1478,30 +1478,44 @@ apiErrAbort(err400, err400Msg, "can not recognize maxItemsOutput '%s' as a number", maxOut); else { if (n == -1) /* can use -1 to indicate as much as allowed */ maxItemsOutput = maxItemLimit; else if (n > maxItemLimit) /* safety check */ apiErrAbort(err400, err400Msg, "requested maxItemsOutput '%s' greater than maximum limit allowed: %d", maxOut, maxItemLimit); else if (n < 1) apiErrAbort(err400, err400Msg, "requested maxItemsOutput '%s' can not be less than one", maxOut, maxItemLimit); else maxItemsOutput = n; } } } /* static void setGlobalCgiVars() */ +static void redirectToHelp() +/* redirect to the help page */ +{ +puts("Content-Type:text/html"); +hPrintf("Status: %d %s\n", err301, err301Msg); +puts("\n"); + +hPrintf("\n"); +hPrintf("\n"); +hPrintf("\n"); +hPrintf("\n"); +hPrintf("\n"); +} + /* Null terminated list of CGI Variables we don't want to save * permanently. */ static char *excludeVars[] = {"Submit", "submit", "sourceSelected", "selectRadio", "ucscGenome", "publicHubs", "clade", NULL,}; int main(int argc, char *argv[]) /* Process command line. */ { enteredMainTime = clock1000(); cgiSpoof(&argc, argv); verboseTimeInit(); /* similar delay system as in DAS server */ botDelay = hgBotDelayTimeFrac(delayFraction); if (botDelay > 0) { if (botDelay > 2000) @@ -1512,21 +1526,27 @@ sleep1000(botDelay); } setGlobalCgiVars(); int timeout = cgiOptionalInt("udcTimeout", 300); if (udcCacheTimeout() < timeout) udcSetCacheTimeout(timeout); knetUdcInstall(); char *pathInfo = getenv("PATH_INFO"); if (isNotEmpty(pathInfo)) /* can get to this immediately, no cart needed */ apiRequest(pathInfo); else { + char *allowApiHtml = cfgOptionDefault("hubApi.allowHtml", "off"); + if (sameWord("on", allowApiHtml)) + { trackCounter = hashNew(0); cartEmptyShellNoContent(doMiddle, hUserCookie(), excludeVars, oldVars); } + else + redirectToHelp(); + } cgiExitTime("hubApi", enteredMainTime); return 0; }