dc98e9649a4105739f9b67322d61c520d3ab10c8 max Thu Aug 21 09:37:03 2025 -0700 making hgTables always set the cookie, which is important for the captcha, refs #36100 diff --git src/hg/lib/cart.c src/hg/lib/cart.c index 6f6e1fa1e6e..4c1e11f227e 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -2708,53 +2708,60 @@ return cart; } static void addHttpHeaders() /* CGIs can initialize the global variable httpHeaders to control their own HTTP * headers. This allows, for example, to prevent web browser caching of hgTracks * responses, but implicitly allow web browser caching everywhere else */ { struct slPair *h; for (h = httpHeaders; h != NULL; h = h->next) { printf("%s: %s\n", h->name, (char *)h->val); } } -void cartWriteHeaderAndCont(struct cart* cart, char *cookieName) -/* write http headers including cookie and content type line */ +void cartWriteHeaderAndCont(struct cart* cart, char *cookieName, char *contType) +/* write http headers including cookie and content type line. + * contType defaults to text/html when NULL. + * cookieName defaults to hUserCookie() when NULL */ { +if (!contType) + contType = "text/html"; +if (!cookieName) + cookieName = hUserCookie(); + addHttpHeaders(); cartWriteCookie(cart, cookieName); -puts("Content-Type: text/html\n"); // puts outputs one newline. Headers requires two. +printf("Content-Type: %s\n\n", contType); cartDidContentType = TRUE; } struct cart *cartAndCookieWithHtml(char *cookieName, char **exclude, struct hash *oldVars, boolean doContentType) /* Load cart from cookie and session cgi variable. Write cookie * and optionally content-type part HTTP preamble to web page. Don't * write any HTML though. */ { // Note: early abort works fine but early warn does not htmlPushEarlyHandlers(); struct cart *cart = cartForSession(cookieName, exclude, oldVars); popWarnHandler(); popAbortHandler(); if (doContentType && !cartDidContentType) - cartWriteHeaderAndCont(cart, cookieName); + cartWriteHeaderAndCont(cart, cookieName, NULL); return cart; } struct cart *cartAndCookie(char *cookieName, char **exclude, struct hash *oldVars) /* Load cart from cookie and session cgi variable. Write cookie and * content-type part HTTP preamble to web page. Don't write any HTML though. */ { return cartAndCookieWithHtml(cookieName, exclude, oldVars, TRUE); } struct cart *cartAndCookieNoContent(char *cookieName, char **exclude, struct hash *oldVars) /* Load cart from cookie and session cgi variable. Don't write out