f57b4c26a1281c52053da0a91d4901d1261a443d kent Mon Jun 15 15:48:41 2015 -0700 Making help text not appear as XML to the browser. diff --git src/hg/das/das.c src/hg/das/das.c index ca18337..2865029 100644 --- src/hg/das/das.c +++ src/hg/das/das.c @@ -30,91 +30,94 @@ static char *version = "1.00"; static char *database = NULL; /* DAS response codes */ #define DAS_OK 200 #define DAS_BAD_COMMAND 400 #define DAS_BAD_DATA_SOURCE 401 #define DAS_BAD_COMMAND_ARGS 402 #define DAS_BAD_REFERENCE_OBJECT 403 #define DAS_BAD_STYLESHEET 404 #define DAS_COORDINATE_ERROR 405 #define DAS_SERVER_ERROR 500 #define DAS_UNIMPLEMENTED_FEATURE 501 -static void dasHead(int code) +static void dasHead(int code, boolean justText) /* Write out very start of DAS header */ { printf("X-DAS-Version: DAS/0.95\n"); printf("X-DAS-Status: %d\n", code); +if (justText) + printf("Content-Type:text\n"); +else printf("Content-Type:text/xml\n"); // these allow access from javascript, see http://www.w3.org/TR/cors/ printf("Access-Control-Allow-Origin: *\n"); printf("Access-Control-Expose-Headers: X-DAS-Version X-DAS-Status X-DAS-Capabilities\n"); printf("\n"); } static void dasHeader(int code) /* Write out DAS header */ { -dasHead(code); +dasHead(code, FALSE); if (code != DAS_OK) exit(-1); printf("<?xml version=\"1.0\" standalone=\"no\"?>\n"); } static char dasStrand(char strand) /* convert a strand to a valid DAS strand (+,-,0) */ { if ((strand == '+') || (strand == '-')) return strand; else return '0'; } void blockHog(char *hogHost, char *hogAddr) /* Compare host/addr to those of an abusive client that we want to block. */ { char *rhost = getenv("REMOTE_HOST"); char *raddr = getenv("REMOTE_ADDR"); if ((rhost != NULL && sameWord(rhost, hogHost)) || (raddr != NULL && sameWord(raddr, hogAddr))) { - dasHead(DAS_OK); + dasHead(DAS_OK, TRUE); printf("Your host, %s, has been sending too many requests lately and is " "unfairly loading our site, impacting performance for other users. " "Please contact genome@cse.ucsc.edu to ask that your site " "be reenabled. Also, please consider downloading sequence and/or " "annotations in bulk -- see http://genome.ucsc.edu/downloads.html.", hogHost); exit(0); } } static void dasHelp(char *s) /* Put up some hopefully helpful information. */ { -dasHead(DAS_OK); +dasHead(DAS_OK, TRUE); puts(s); exit(0); } static void dasAbout() /* Print a little info when they just hit cgi-bin/das. */ { -dasHead(DAS_OK); +dasHead(DAS_OK, TRUE); dasHelp("UCSC DAS Server.\n" "See http://www.biodas.org for more info on DAS.\n" "Try http://genome.ucsc.edu/cgi-bin/das/dsn for a list of databases.\n" "See our DAS FAQ (http://genome.ucsc.edu/FAQ/FAQdownloads#download23)\n" "for more information. Alternatively, we also provide query capability\n" "through our MySQL server; please see our FAQ for details\n" "(http://genome.ucsc.edu/FAQ/FAQdownloads#download29).\n\n" "Note that DAS is an inefficient protocol which does not support\n" "all types of annotation in our database. We recommend you\n" "access the UCSC database by downloading the tab-separated files in\n" "the downloads section (http://hgdownload.cse.ucsc.edu/downloads.html)\n" "or by using the Table Browser (http://genome.ucsc.edu/cgi-bin/hgTables)\n" "instead of DAS in most circumstances."); exit(0); }