3ac146126c6b73e2870939c95e62e843dc09f2d3 galt Tue May 30 22:31:24 2017 -0700 Fixes problem where http header gets output twice when calling web.c::webAbort() from hgc.c. fixes #19470 diff --git src/hg/lib/web.c src/hg/lib/web.c index 3435b04..b857d05 100644 --- src/hg/lib/web.c +++ src/hg/lib/web.c @@ -288,30 +288,40 @@ void webStartWrapperGateway(struct cart *theCart, char *db, char *format, va_list args, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader) /* output a CGI and HTML header with the given title in printf format */ { webStartWrapperGatewayHeader(theCart, db, "", format, args, withHttpHeader, withLogo, skipSectionHeader); } void webStartWrapper(struct cart *theCart, char *db, char *format, va_list args, boolean withHttpHeader, boolean withLogo) /* allows backward compatibility with old webStartWrapper that doesn't contain the "skipHeader" arg */ /* output a CGI and HTML header with the given title in printf format */ { webStartWrapperGatewayHeader(theCart, db, "", format, args, withHttpHeader, withLogo, FALSE); } +void webStartExt(boolean withHttpHeader, struct cart *theCart, char *db, char *format, ...) +/* Print out pretty wrapper around things when not + * from cart. Do not output an http header.*/ +{ +va_list args; +va_start(args, format); +webStartWrapper(theCart, db, format, args, withHttpHeader, TRUE); +va_end(args); +} + void webStart(struct cart *theCart, char *db, char *format, ...) /* Print out pretty wrapper around things when not * from cart. */ { va_list args; va_start(args, format); webStartWrapper(theCart, db, format, args, TRUE, TRUE); va_end(args); } void webStartHeader(struct cart *theCart, char *db, char *headerText, char *format, ...) /* Print out pretty wrapper around things when not from cart. * Include headerText in the html header. */ { va_list args; @@ -520,54 +530,74 @@ // because they want to output text unless we hit this condition: puts("Content-type:text/html\n"); cartWebStart(errCart, errDb, "Error"); } htmlVaWarn(format, args); printf("\n<!-- HGERROR -->\n\n\n"); } boolean webGotWarnings() /* Return TRUE if webVaWarn has been called. */ { return gotWarnings; } -void webAbort(char* title, char* format, ...) +void webAbortExt(boolean withHttpHeader, char* title, char *format, va_list args) /* an abort function that outputs a error page */ { -va_list args; -va_start(args, format); /* output the header */ if(!webHeadAlreadyOutputed) - webStart(errCart, NULL, "%s", title); + webStartExt(withHttpHeader, errCart, NULL, "%s", title); /* in text mode, have a different error */ if(webInTextMode) printf("\n\n\n %s\n\n", title); vprintf(format, args); + printf("<!-- HGERROR -->\n"); printf("\n\n"); webEnd(); -va_end(args); exit(0); } +void webAbortNoHttpHeader(char* title, char* format, ...) +/* an abort function that outputs a error page. No http header output. */ +{ +va_list args; +va_start(args, format); + +webAbortExt(FALSE, title, format, args); + +va_end(args); +} + +void webAbort(char* title, char* format, ...) +/* an abort function that outputs a error page */ +{ +va_list args; +va_start(args, format); + +webAbortExt(TRUE, title, format, args); + +va_end(args); +} + void printCladeListHtml(char *genome, char *event, char *javascript) /* Make an HTML select input listing the clades. */ { char **row = NULL; char *clades[128]; char *labels[128]; char *defaultClade = hClade(genome); char *defaultLabel = NULL; int numClades = 0; struct sqlConnection *conn = hConnectCentral(); // after hClade since it access hgcentral too // get only the clades that have actual active genomes char query[4096]; sqlSafef(query, sizeof query, "SELECT DISTINCT(c.name), c.label " // mysql 5.7: SELECT list w/DISTINCT must include all fields in ORDER BY list (#18626)