]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/squid/squid-3.5-14073.patch
Merge branch 'unbound' into next
[ipfire-2.x.git] / src / patches / squid / squid-3.5-14073.patch
1 ------------------------------------------------------------
2 revno: 14073
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>
7 branch nick: 3.5
8 timestamp: Wed 2016-08-17 17:10:37 +1200
9 message:
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-\
19 # s4102klt2ei25tsm
20 #
21 # Begin patch
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
25 @@ -572,6 +572,38 @@
26 /* NOTREACHED */
27 }
28
29 +/// assemble a variant key (vary-mark) from the given Vary header and HTTP request
30 +static void
31 +assembleVaryKey(String &vary, SBuf &vstr, const HttpRequest &request)
32 +{
33 + static const SBuf asterisk("*");
34 + const char *pos = nullptr;
35 + const char *item = nullptr;
36 + int ilen = 0;
37 +
38 + while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
39 + SBuf name(item, ilen);
40 + if (name == asterisk) {
41 + vstr.clear();
42 + break;
43 + }
44 + name.toLower();
45 + if (!vstr.isEmpty())
46 + vstr.append(", ", 2);
47 + vstr.append(name);
48 + String hdr(request.header.getByName(name.c_str()));
49 + const char *value = hdr.termedBuf();
50 + if (value) {
51 + value = rfc1738_escape_part(value);
52 + vstr.append("=\"", 2);
53 + vstr.append(value);
54 + vstr.append("\"", 1);
55 + }
56 +
57 + hdr.clean();
58 + }
59 +}
60 +
61 /*
62 * For Vary, store the relevant request headers as
63 * virtual headers in the reply
64 @@ -580,81 +612,16 @@
65 SBuf
66 httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
67 {
68 - String vary, hdr;
69 - const char *pos = NULL;
70 - const char *item;
71 - const char *value;
72 - int ilen;
73 SBuf vstr;
74 - static const SBuf asterisk("*");
75 + String vary;
76
77 vary = reply->header.getList(HDR_VARY);
78 -
79 - while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
80 - char *name = (char *)xmalloc(ilen + 1);
81 - xstrncpy(name, item, ilen + 1);
82 - Tolower(name);
83 -
84 - if (strcmp(name, "*") == 0) {
85 - /* Can not handle "Vary: *" withtout ETag support */
86 - safe_free(name);
87 - vstr.clear();
88 - break;
89 - }
90 -
91 - if (!vstr.isEmpty())
92 - vstr.append(", ", 2);
93 - vstr.append(name);
94 - hdr = request->header.getByName(name);
95 - safe_free(name);
96 - value = hdr.termedBuf();
97 -
98 - if (value) {
99 - value = rfc1738_escape_part(value);
100 - vstr.append("=\"", 2);
101 - vstr.append(value);
102 - vstr.append("\"", 1);
103 - }
104 -
105 - hdr.clean();
106 - }
107 -
108 + assembleVaryKey(vary, vstr, *request);
109 +
110 +#if X_ACCELERATOR_VARY
111 vary.clean();
112 -#if X_ACCELERATOR_VARY
113 -
114 - pos = NULL;
115 vary = reply->header.getList(HDR_X_ACCELERATOR_VARY);
116 -
117 - while (strListGetItem(&vary, ',', &item, &ilen, &pos)) {
118 - char *name = (char *)xmalloc(ilen + 1);
119 - xstrncpy(name, item, ilen + 1);
120 - Tolower(name);
121 -
122 - if (strcmp(name, "*") == 0) {
123 - /* Can not handle "Vary: *" withtout ETag support */
124 - safe_free(name);
125 - vstr.clear();
126 - break;
127 - }
128 -
129 - if (!vstr.isEmpty())
130 - vstr.append(", ", 2);
131 - vstr.append(name);
132 - hdr = request->header.getByName(name);
133 - safe_free(name);
134 - value = hdr.termedBuf();
135 -
136 - if (value) {
137 - value = rfc1738_escape_part(value);
138 - vstr.append("=\"", 2);
139 - vstr.append(value);
140 - vstr.append("\"", 1);
141 - }
142 -
143 - hdr.clean();
144 - }
145 -
146 - vary.clean();
147 + assembleVaryKey(vary, vstr, *request);
148 #endif
149
150 debugs(11, 3, vstr);
151