1 ------------------------------------------------------------
3 revision-id: squid3@treenet.co.nz-20160817051037-p0kaj2iw2u4u8iqj
4 parent: squid3@treenet.co.nz-20160817025828-s4102klt2ei25tsm
5 fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4563
6 committer: Amos Jeffries <squid3@treenet.co.nz>
8 timestamp: Wed 2016-08-17 17:10:37 +1200
10 Bug 4563: duplicate code in httpMakeVaryMark
11 ------------------------------------------------------------
12 # Bazaar merge directive format 2 (Bazaar 0.90)
13 # revision_id: squid3@treenet.co.nz-20160817051037-p0kaj2iw2u4u8iqj
14 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
15 # testament_sha1: bba9a17715b8759e9d70db2c75f70f3c6152ae8a
16 # timestamp: 2016-08-17 05:50:53 +0000
17 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
18 # base_revision_id: squid3@treenet.co.nz-20160817025828-\
22 === modified file 'src/http.cc'
23 --- src/http.cc 2016-04-01 06:15:31 +0000
24 +++ src/http.cc 2016-08-17 05:10:37 +0000
29 +/// assemble a variant key (vary-mark) from the given Vary header and HTTP request
31 +assembleVaryKey(String &vary, SBuf &vstr, const HttpRequest &request)
33 + static const SBuf asterisk("*");
34 + const char *pos = nullptr;
35 + const char *item = nullptr;
38 + while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
39 + SBuf name(item, ilen);
40 + if (name == asterisk) {
45 + if (!vstr.isEmpty())
46 + vstr.append(", ", 2);
48 + String hdr(request.header.getByName(name.c_str()));
49 + const char *value = hdr.termedBuf();
51 + value = rfc1738_escape_part(value);
52 + vstr.append("=\"", 2);
54 + vstr.append("\"", 1);
62 * For Vary, store the relevant request headers as
63 * virtual headers in the reply
66 httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
69 - const char *pos = NULL;
74 - static const SBuf asterisk("*");
77 vary = reply->header.getList(HDR_VARY);
79 - while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
80 - char *name = (char *)xmalloc(ilen + 1);
81 - xstrncpy(name, item, ilen + 1);
84 - if (strcmp(name, "*") == 0) {
85 - /* Can not handle "Vary: *" withtout ETag support */
91 - if (!vstr.isEmpty())
92 - vstr.append(", ", 2);
94 - hdr = request->header.getByName(name);
96 - value = hdr.termedBuf();
99 - value = rfc1738_escape_part(value);
100 - vstr.append("=\"", 2);
101 - vstr.append(value);
102 - vstr.append("\"", 1);
108 + assembleVaryKey(vary, vstr, *request);
110 +#if X_ACCELERATOR_VARY
112 -#if X_ACCELERATOR_VARY
115 vary = reply->header.getList(HDR_X_ACCELERATOR_VARY);
117 - while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
118 - char *name = (char *)xmalloc(ilen + 1);
119 - xstrncpy(name, item, ilen + 1);
122 - if (strcmp(name, "*") == 0) {
123 - /* Can not handle "Vary: *" withtout ETag support */
129 - if (!vstr.isEmpty())
130 - vstr.append(", ", 2);
132 - hdr = request->header.getByName(name);
134 - value = hdr.termedBuf();
137 - value = rfc1738_escape_part(value);
138 - vstr.append("=\"", 2);
139 - vstr.append(value);
140 - vstr.append("\"", 1);
147 + assembleVaryKey(vary, vstr, *request);