55735184a6c373f0802e54ca19fe0128ec912ba0 angie Wed Jan 7 12:33:49 2015 -0800 Adding cartEmptyShellNoContent so a CGI can postpone the Content-Type decision to doMiddle. diff --git src/hg/lib/cart.c src/hg/lib/cart.c index 2f70857..c2bef94 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -1735,42 +1735,65 @@ safef(titlePlus,sizeof(titlePlus), "%s%s - %s",trackHubSkipHubName(org), extra, title ); else if (pos != NULL && org == NULL) safef(titlePlus,sizeof(titlePlus), "%s - %s",pos, title ); else if (pos == NULL && org == NULL) safef(titlePlus,sizeof(titlePlus), "%s", title ); else safef(titlePlus,sizeof(titlePlus), "%s%s %s - %s",trackHubSkipHubName(org), extra,pos, title ); popWarnHandler(); setThemeFromCart(cart); htmStartWithHead(stdout, head, titlePlus); cartWarnCatcher(doMiddle, cart, htmlVaWarn); cartCheckout(&cart); cartFooter(); } +static void cartEmptyShellMaybeContent(void (*doMiddle)(struct cart *cart), char *cookieName, + char **exclude, struct hash *oldVars, boolean doContentType) +/* Get cart and cookies and set up error handling. + * If doContentType, print out Content-type:text/html + * but don't start writing any html yet. + * The doMiddleFunction has to call cartHtmlStart(title), and + * cartHtmlEnd(), as well as writing the body of the HTML. + * oldVars - those in cart that are overlayed by cgi-vars are + * put in optional hash oldVars. */ +{ +struct cart *cart = cartAndCookieWithHtml(cookieName, exclude, oldVars, doContentType); +setThemeFromCart(cart); +cartWarnCatcher(doMiddle, cart, cartEarlyWarningHandler); +cartCheckout(&cart); +} + void cartEmptyShell(void (*doMiddle)(struct cart *cart), char *cookieName, char **exclude, struct hash *oldVars) /* Get cart and cookies and set up error handling, but don't start writing any * html yet. The doMiddleFunction has to call cartHtmlStart(title), and * cartHtmlEnd(), as well as writing the body of the HTML. * oldVars - those in cart that are overlayed by cgi-vars are * put in optional hash oldVars. */ { -struct cart *cart = cartAndCookie(cookieName, exclude, oldVars); -setThemeFromCart(cart); -cartWarnCatcher(doMiddle, cart, cartEarlyWarningHandler); -cartCheckout(&cart); +cartEmptyShellMaybeContent(doMiddle, cookieName, exclude, oldVars, TRUE); +} + +void cartEmptyShellNoContent(void (*doMiddle)(struct cart *cart), char *cookieName, + char **exclude, struct hash *oldVars) +/* Get cart and cookies and set up error handling. + * The doMiddle function must write the Content-Type header line. + * oldVars - those in cart that are overlayed by cgi-vars are + * put in optional hash oldVars. */ +{ +cartEmptyShellMaybeContent(doMiddle, cookieName, exclude, oldVars, FALSE); } void cartHtmlShell(char *title, void (*doMiddle)(struct cart *cart), char *cookieName, char **exclude, struct hash *oldVars) /* Load cart from cookie and session cgi variable. Write web-page * preamble, call doMiddle with cart, and write end of web-page. * Exclude may be NULL. If it exists it's a comma-separated list of * variables that you don't want to save in the cart between * invocations of the cgi-script. */ { cartHtmlShellWithHead("", title, doMiddle, cookieName, exclude, oldVars); } void cartSetDbConnector(DbConnector connector) /* Set the connector that will be used by the cart to connect to the