On Jan 11, 2008 1:02 AM, Adrian Chadd <adrian@xxxxxxxxxxxxxxx> wrote: > Works for them. :) Something to fix that sort of thing may appear > sometime in the future but it depends on interest and funding. Btw, the patch posted on Domas' blog doesn't work as it doesn't filter the Vary headers. Moreover as I had a problem before fixing my own patch, I wonder if removing the line strCat(request->vary_encoding, ""); doesn't cause a core dump when Accept-Encoding is empty or missing. Here is a slightly different patch based on the same concepts which works for us. It maintains only 2 versions of the cache depending on if the Accept-Encoding header contains gzip or not. Note that I'm not especially fluent in C so it may be a bit ugly. If someone can proofread it, I'll appreciate. -- Guillaume
--- squid-2.6.STABLE18/src/http.c.orig 2007-11-26 06:04:30.000000000 -0500 +++ squid-2.6.STABLE18/src/http.c 2008-01-11 09:48:42.252702122 -0500 @@ -367,17 +367,6 @@ char *name = xmalloc(ilen + 1); xstrncpy(name, item, ilen + 1); Tolower(name); - if (strcmp(name, "accept-encoding") == 0) { - aclCheck_t checklist; - memset(&checklist, 0, sizeof(checklist)); - checklist.request = request; - checklist.reply = reply; - if (Config.accessList.vary_encoding && aclCheckFast(Config.accessList.vary_encoding, &checklist)) { - stringClean(&request->vary_encoding); - request->vary_encoding = httpHeaderGetStrOrList(&request->header, HDR_ACCEPT_ENCODING); - strCat(request->vary_encoding, ""); - } - } if (strcmp(name, "*") == 0) { /* Can not handle "Vary: *" efficiently, bail out making the response not cached */ safe_free(name); @@ -386,15 +375,39 @@ break; } strListAdd(&vstr, name, ','); - hdr = httpHeaderGetByName(&request->header, name); - safe_free(name); - value = strBuf(hdr); - if (value) { - value = rfc1738_escape_part(value); - stringAppend(&vstr, "=\"", 2); - stringAppend(&vstr, value, strlen(value)); - stringAppend(&vstr, "\"", 1); + if (strcmp(name, "accept-encoding") == 0) { + aclCheck_t checklist; + memset(&checklist, 0, sizeof(checklist)); + checklist.request = request; + checklist.reply = reply; + + hdr = httpHeaderGetStrOrList(&request->header, HDR_ACCEPT_ENCODING); + strCat(hdr, ""); + + String vary_encoding; + if (strstr(strBuf(hdr), "gzip")) { + stringAppend(&vstr, "=\"", 2); + stringAppend(&vstr, "gzip", 4); + stringAppend(&vstr, "\"", 1); + stringInit(&vary_encoding, "gzip"); + } else { + stringInit(&vary_encoding, ""); + } + if (Config.accessList.vary_encoding && aclCheckFast(Config.accessList.vary_encoding, &checklist)) { + stringReset(&request->vary_encoding, strBuf(vary_encoding)); + } + stringClean(&vary_encoding); + } else { + hdr = httpHeaderGetByName(&request->header, name); + value = strBuf(hdr); + if (value) { + value = rfc1738_escape_part(value); + stringAppend(&vstr, "=\"", 2); + stringAppend(&vstr, value, strlen(value)); + stringAppend(&vstr, "\"", 1); + } } + safe_free(name); stringClean(&hdr); } safe_free(request->vary_hdr); @@ -1168,6 +1181,11 @@ if (!opt_forwarded_for) httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e)); break; + case HDR_ACCEPT_ENCODING: + /* Strip everything other encoding, except gzip. x-gzip is equivalent of gzip */ + if (strstr(strBuf(e->value),"gzip")) + httpHeaderPutStr(hdr_out, HDR_ACCEPT_ENCODING, "gzip"); + break; case HDR_RANGE: case HDR_IF_RANGE: case HDR_REQUEST_RANGE: