06ce406a7fe0566c6f6984b445c9035088c1bd38 hiram Mon Feb 11 15:17:30 2019 -0800 now with correct application/json content type header refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index d67abcf..a554615 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -876,36 +876,40 @@ getDbAndGenome(cart, &database, &genome, oldVars); initGenbankTableNames(database); char *docRoot = cfgOptionDefault("browser.documentRoot", DOCUMENT_ROOT); int timeout = cartUsualInt(cart, "udcTimeout", 300); if (udcCacheTimeout() < timeout) udcSetCacheTimeout(timeout); knetUdcInstall(); char *pathInfo = getenv("PATH_INFO"); if (isNotEmpty(pathInfo)) { + puts("Content-Type:application/json"); + puts("\n"); /* skip the first leading slash to simplify chopByChar parsing */ pathInfo += 1; setupFunctionHash(); apiFunctionSwitch(pathInfo); return; } +puts("Content-Type:text/html"); +puts("\n"); struct dbDb *dbList = ucscDbDb(); char **ucscDbList = NULL; int listSize = slCount(dbList); AllocArray(ucscDbList, listSize); struct dbDb *el = dbList; int ucscDataBaseCount = 0; int maxDbNameWidth = 0; for ( ; el != NULL; el = el->next ) { ucscDbList[ucscDataBaseCount++] = el->name; if (strlen(el->name) > maxDbNameWidth) maxDbNameWidth = strlen(el->name); } maxDbNameWidth += 1; @@ -925,32 +929,32 @@ long lastTime = clock1000(); struct trackHub *hub = trackHubOpen(urlInput, ""); if (measureTiming) { long thisTime = clock1000(); hPrintf("hub open time: %ld millis
\n", thisTime - lastTime); } hPrintf("

ucscDb: '%s'

\n", ucscDb); struct trackHubGenome *hubGenome = hub->genomeList; hPrintf("

Example URLs to return json data structures:

\n"); hPrintf("\n"); hPrintf("

cart dump

"); hPrintf("
\n");
 cartDump(cart);
 hPrintf("
\n"); hPrintf("
\n\n", "../cgi-bin/hubApi"); hPrintf("Select public hub: "); @@ -1018,18 +1022,18 @@ cartWebEnd(); } /* void doMiddle(struct cart *theCart) */ /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {"Submit", "submit", NULL,}; int main(int argc, char *argv[]) /* Process command line. */ { enteredMainTime = clock1000(); cgiSpoof(&argc, argv); measureTiming = TRUE; verboseTimeInit(); trackCounter = hashNew(0); -cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); +cartEmptyShellNoContent(doMiddle, hUserCookie(), excludeVars, oldVars); return 0; }