r30690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30689‎ | r30690 | r30691 >
Date:04:34, 8 February 2008
Author:tstarling
Status:old
Tags:
Comment:
X-Vary-Options feature. Will submit it to squid-dev for review shortly.
Modified paths:
  • /trunk/debs/squid/debian/changelog (modified) (history)
  • /trunk/debs/squid/debian/patches/00list (modified) (history)
  • /trunk/debs/squid/debian/patches/26-vary_options.dpatch (added) (history)
  • /trunk/debs/squid/debian/rules (modified) (history)

Diff [purge]

Index: trunk/debs/squid/debian/patches/26-vary_options.dpatch
@@ -0,0 +1,253 @@
 2+#! /bin/sh /usr/share/dpatch/dpatch-run
 3+## vary_options.dpatch by <tstarling@wikimedia.org>
 4+##
 5+## All lines beginning with `## DP:' are a description of the patch.
 6+## DP: Adds support for the X-Vary-Options response header
 7+
 8+@DPATCH@
 9+--- squid-2.6.18.orig/src/defines.h 2008-02-07 22:05:02.000000000 +1100
 10+@@ -364,4 +364,10 @@
 11+ #define DLINK_ISEMPTY(n) ( (n).head == NULL )
 12+ #define DLINK_HEAD(n) ( (n).head->data )
 13+
 14++
 15++/* Hack to avoid re-running autoconf/automake -- TS */
 16++#ifndef VARY_OPTIONS
 17++#define VARY_OPTIONS 1
 18++#endif
 19++
 20+ #endif /* SQUID_DEFINES_H */
 21+
 22+diff -ru squid-2.6.18.orig/src/enums.h squid-2.6.18/src/enums.h
 23+--- squid-2.6.18.orig/src/enums.h 2008-02-07 19:28:38.000000000 +1100
 24+@@ -256,13 +256,16 @@
 25+ #if X_ACCELERATOR_VARY
 26+ HDR_X_ACCELERATOR_VARY,
 27+ #endif
 28++#if VARY_OPTIONS
 29++ HDR_X_VARY_OPTIONS,
 30++#endif
 31+ HDR_X_ERROR_URL, /* errormap, requested URL */
 32+ HDR_X_ERROR_STATUS, /* errormap, received HTTP status line */
 33+ HDR_FRONT_END_HTTPS,
 34+ HDR_PROXY_SUPPORT,
 35+diff -ru squid-2.6.18.orig/src/http.c squid-2.6.18/src/http.c
 36+--- squid-2.6.18.orig/src/http.c 2008-02-07 19:28:38.000000000 +1100
 37+@@ -353,20 +353,48 @@
 38+ String vstr = StringNull;
 39+
 40+ stringClean(&vstr);
 41+- hdr = httpHeaderGetList(&reply->header, HDR_VARY);
 42+- if (strBuf(hdr))
 43++#if VARY_OPTIONS
 44++ hdr = httpHeaderGetList(&reply->header, HDR_X_VARY_OPTIONS);
 45++ if (strBuf(hdr)) {
 46+ strListAdd(&vary, strBuf(hdr), ',');
 47+- stringClean(&hdr);
 48++ stringClean(&hdr);
 49++ } else {
 50++ stringClean(&hdr);
 51++#endif
 52++
 53++ hdr = httpHeaderGetList(&reply->header, HDR_VARY);
 54++ if (strBuf(hdr))
 55++ strListAdd(&vary, strBuf(hdr), ',');
 56++ stringClean(&hdr);
 57+ #if X_ACCELERATOR_VARY
 58+- hdr = httpHeaderGetList(&reply->header, HDR_X_ACCELERATOR_VARY);
 59+- if (strBuf(hdr))
 60+- strListAdd(&vary, strBuf(hdr), ',');
 61+- stringClean(&hdr);
 62++ hdr = httpHeaderGetList(&reply->header, HDR_X_ACCELERATOR_VARY);
 63++ if (strBuf(hdr))
 64++ strListAdd(&vary, strBuf(hdr), ',');
 65++ stringClean(&hdr);
 66++#endif
 67++#if VARY_OPTIONS
 68++ }
 69+ #endif
 70+ while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
 71+- char *name = xmalloc(ilen + 1);
 72+- xstrncpy(name, item, ilen + 1);
 73+- Tolower(name);
 74++ const char *sc_item, *sc_pos = NULL;
 75++ int sc_ilen;
 76++ String zitem;
 77++ char *name = NULL;
 78++ String value_spec = StringNull;
 79++ int need_value = 1;
 80++
 81++ stringLimitInit(&zitem, item, ilen);
 82++
 83++ /* Get the header name */
 84++ if (strListGetItem(&zitem, ';', &sc_item, &sc_ilen, &sc_pos)) {
 85++ name = xmalloc(sc_ilen + 1);
 86++ xstrncpy(name, sc_item, sc_ilen + 1);
 87++ Tolower(name);
 88++ } else {
 89++ name = xmalloc(1);
 90++ *name = '\0';
 91++ }
 92++
 93+ if (strcmp(name, "accept-encoding") == 0) {
 94+ aclCheck_t checklist;
 95+ memset(&checklist, 0, sizeof(checklist));
 96+@@ -381,22 +409,74 @@
 97+ if (strcmp(name, "*") == 0) {
 98+ /* Can not handle "Vary: *" efficiently, bail out making the response not cached */
 99+ safe_free(name);
 100++ stringClean(&zitem);
 101+ stringClean(&vary);
 102+ stringClean(&vstr);
 103+ break;
 104+ }
 105+- strListAdd(&vstr, name, ',');
 106++
 107++ /* Fetch the header string */
 108+ hdr = httpHeaderGetByName(&request->header, name);
 109+- safe_free(name);
 110+- value = strBuf(hdr);
 111+- if (value) {
 112+- value = rfc1738_escape_part(value);
 113+- stringAppend(&vstr, "=\"", 2);
 114+- stringAppend(&vstr, value, strlen(value));
 115+- stringAppend(&vstr, "\"", 1);
 116++
 117++ /* Process the semicolon-separated options */
 118++#ifdef VARY_OPTIONS
 119++ while (strListGetItem(&zitem, ';', &sc_item, &sc_ilen, &sc_pos)) {
 120++ char *opt_name = xmalloc(sc_ilen + 1);
 121++ char *opt_value;
 122++ char *eqpos;
 123++ xstrncpy(opt_name, sc_item, sc_ilen + 1);
 124++ eqpos = strchr(opt_name, '=');
 125++ if (!eqpos) {
 126++ opt_value = NULL;
 127++ } else {
 128++ *eqpos = '\0';
 129++ opt_value = eqpos + 1;
 130++ }
 131++ Tolower(opt_name);
 132++
 133++ if (strcmp(opt_name, "list-contains") == 0 && opt_value) {
 134++ if (strListIsMember(&hdr, opt_value, ',')) {
 135++ opt_value = rfc1738_escape_part(opt_value);
 136++ strListAdd(&value_spec, "list-contains[\"", ';');
 137++ stringAppend(&value_spec, opt_value, strlen(opt_value));
 138++ stringAppend(&value_spec, "\"]", 2);
 139++ }
 140++ need_value = 0;
 141++ } else if (strcmp(opt_name, "string-contains") == 0 && opt_value) {
 142++ if (strIsSubstr(&hdr, opt_value)) {
 143++ opt_value = rfc1738_escape_part(opt_value);
 144++ strListAdd(&value_spec, "string-contains[\"", ';');
 145++ stringAppend(&value_spec, opt_value, strlen(opt_value));
 146++ stringAppend(&value_spec, "\"]", 2);
 147++ }
 148++ need_value = 0;
 149++ }
 150++ safe_free(opt_name);
 151++ }
 152++#endif
 153++
 154++ if (need_value) {
 155++ value = strBuf(hdr);
 156++ if (value) {
 157++ value = rfc1738_escape_part(value);
 158++ strListAdd(&value_spec, "\"", ';');
 159++ stringAppend(&value_spec, value, strlen(value));
 160++ stringAppend(&value_spec, "\"", 1);
 161++ }
 162++ }
 163++
 164++ strListAdd(&vstr, name, ',');
 165++ stringAppend(&vstr, "=", 1);
 166++ if (strBuf(value_spec)) {
 167++ stringAppend(&vstr, strBuf(value_spec), strLen(value_spec));
 168+ }
 169++
 170+ stringClean(&hdr);
 171++ stringClean(&value_spec);
 172++ stringClean(&zitem);
 173++ safe_free(name);
 174+ }
 175++
 176+ safe_free(request->vary_hdr);
 177+ safe_free(request->vary_headers);
 178+ if (strBuf(vary) && strBuf(vstr)) {
 179+diff -ru squid-2.6.18.orig/src/HttpHeader.c squid-2.6.18/src/HttpHeader.c
 180+--- squid-2.6.18.orig/src/HttpHeader.c 2007-12-21 20:56:53.000000000 +1100
 181+@@ -133,6 +133,9 @@
 182+ #if X_ACCELERATOR_VARY
 183+ {"X-Accelerator-Vary", HDR_X_ACCELERATOR_VARY, ftStr},
 184+ #endif
 185++#if VARY_OPTIONS
 186++ {"X-Vary-Options", HDR_X_VARY_OPTIONS, ftStr},
 187++#endif
 188+ {"X-Error-URL", HDR_X_ERROR_URL, ftStr},
 189+ {"X-Error-Status", HDR_X_ERROR_STATUS, ftInt},
 190+ {"Front-End-Https", HDR_FRONT_END_HTTPS, ftStr},
 191+@@ -173,6 +176,9 @@
 192+ #if X_ACCELERATOR_VARY
 193+ HDR_X_ACCELERATOR_VARY,
 194+ #endif
 195++#if VARY_OPTIONS
 196++ HDR_X_VARY_OPTIONS,
 197++#endif
 198+ HDR_X_FORWARDED_FOR
 199+ };
 200+
 201+@@ -210,6 +216,9 @@
 202+ #if X_ACCELERATOR_VARY
 203+ HDR_X_ACCELERATOR_VARY,
 204+ #endif
 205++#if VARY_OPTIONS
 206++ HDR_X_VARY_OPTIONS,
 207++#endif
 208+ HDR_X_SQUID_ERROR
 209+ };
 210+
 211+diff -ru squid-2.6.18.orig/src/store.c squid-2.6.18/src/store.c
 212+--- squid-2.6.18.orig/src/store.c 2008-02-07 19:28:38.000000000 +1100
 213+@@ -1042,16 +1042,28 @@
 214+ String vary = StringNull;
 215+ vary_id_t vary_id;
 216+ String varyhdr;
 217+- varyhdr = httpHeaderGetList(&mem->reply->header, HDR_VARY);
 218+- if (strBuf(varyhdr))
 219++#if VARY_OPTIONS
 220++ /* X-Vary-Options overrides the other vary headers for caches that support it */
 221++ varyhdr = httpHeaderGetList(&mem->reply->header, HDR_X_VARY_OPTIONS);
 222++ if (strBuf(varyhdr)) {
 223+ strListAdd(&vary, strBuf(varyhdr), ',');
 224+- stringClean(&varyhdr);
 225++ stringClean(&varyhdr);
 226++ } else {
 227++ stringClean(&varyhdr);
 228++#endif
 229++ varyhdr = httpHeaderGetList(&mem->reply->header, HDR_VARY);
 230++ if (strBuf(varyhdr))
 231++ strListAdd(&vary, strBuf(varyhdr), ',');
 232++ stringClean(&varyhdr);
 233+ #if X_ACCELERATOR_VARY
 234+- /* This needs to match the order in http.c:httpMakeVaryMark */
 235+- varyhdr = httpHeaderGetList(&mem->reply->header, HDR_X_ACCELERATOR_VARY);
 236+- if (strBuf(varyhdr))
 237+- strListAdd(&vary, strBuf(varyhdr), ',');
 238+- stringClean(&varyhdr);
 239++ /* This needs to match the order in http.c:httpMakeVaryMark */
 240++ varyhdr = httpHeaderGetList(&mem->reply->header, HDR_X_ACCELERATOR_VARY);
 241++ if (strBuf(varyhdr))
 242++ strListAdd(&vary, strBuf(varyhdr), ',');
 243++ stringClean(&varyhdr);
 244++#endif
 245++#if VARY_OPTIONS
 246++ }
 247+ #endif
 248+ /* Create or update the vary object */
 249+ vary_id = storeAddVary(mem->url, mem->log_url, mem->method, newkey, httpHeaderGetStr(&mem->reply->header, HDR_ETAG), strBuf(vary), mem->vary_headers, mem->vary_encoding);
Property changes on: trunk/debs/squid/debian/patches/26-vary_options.dpatch
___________________________________________________________________
Added: svn:executable
1250 + *
Index: trunk/debs/squid/debian/patches/00list
@@ -4,7 +4,7 @@
55 06-unlinkd
66 20-wikimedia-errors
77 21-nomangle-requestCC
8 -22-normalize-requestAE
98 22-udplog
109 23-variant-invalidation
1110 25-coss-remove-swap-log
 11+26-vary_options.dpatch
Index: trunk/debs/squid/debian/changelog
@@ -1,3 +1,9 @@
 2+squid (2.6.18-1wm2) gutsy; urgency=low
 3+
 4+ * Added X-Vary-Options feature. Replaces 22-normalize-requestAE.dpatch .
 5+
 6+ -- Tim Starling <tstarling@wikimedia.org> Thu, 07 Feb 2008 22:23:58 +1100
 7+
28 squid (2.6.18-1wm1) edgy; urgency=high
39
410 * New upstream release
Index: trunk/debs/squid/debian/rules
@@ -151,6 +151,7 @@
152152 --with-maxfd=65536 \
153153 --enable-stacktraces \
154154 --enable-dlmalloc=-ltcmalloc \
 155+ --enable-vary-options \
155156 $(DEB_HOST_ARCH_CPU)-debian-$(DEB_HOST_ARCH_OS)
156157 ifeq ($(DEB_HOST_ARCH_OS), linux)
157158 endif

Status & tagging log