]>
Commit | Line | Data |
---|---|---|
07a3710e JR |
1 | diff -uNrw squid-3.2.0.18/src/client_side.cc squid-3.2.0.18/src/client_side.cc |
2 | --- squid-3.2.0.18/src/client_side.cc 2012-07-18 19:36:09.982711673 +0400 | |
3 | +++ squid-3.2.0.18/src/client_side.cc 2012-07-18 19:47:28.594672449 +0400 | |
4 | @@ -1349,6 +1349,15 @@ | |
5 | { | |
6 | reply = rep; | |
7 | ||
8 | + /* Remove our HDR_X_VARY_FOR hack if present. | |
9 | + * Client won't get the joke anyway. | |
10 | + */ | |
11 | + if (rep && rep->header.has(HDR_X_VARY_FOR)) | |
12 | + { | |
13 | + debugs(11,3, HERE << "HDR_X_VARY_FOR hack detected. Cleaning it up"); | |
14 | + rep->header.delById(HDR_X_VARY_FOR); | |
15 | + } | |
16 | + | |
17 | if (http->request->range) | |
18 | buildRangeHeader(rep); | |
19 | } | |
20 | diff -uNrw squid-3.2.0.18/src/http.cc squid-3.2.0.18/src/http.cc | |
21 | --- squid-3.2.0.18/src/http.cc 2012-07-18 19:36:09.962712057 +0400 | |
22 | +++ squid-3.2.0.18/src/http.cc 2012-07-18 19:40:02.442715425 +0400 | |
23 | @@ -880,6 +880,12 @@ | |
24 | } | |
25 | ||
26 | entry->mem_obj->vary_headers = xstrdup(vary); | |
27 | + /* XXX: Currently we are losing vary_headers when | |
28 | + * saving objects to shm, so we now add them as header | |
29 | + * and remove on preparing client reply. | |
30 | + */ | |
31 | + debugs(11,3,"haveParsedReplyHeaders: inserting HDR_X_VARY_FOR into the reply"); | |
32 | + rep->header.putStr(HDR_X_VARY_FOR, entry->mem_obj->vary_headers); | |
33 | } | |
34 | ||
35 | /* | |
36 | diff -uNrw squid-3.2.0.18/src/HttpHeader.cc squid-3.2.0.18/src/HttpHeader.cc | |
37 | --- squid-3.2.0.18/src/HttpHeader.cc 2012-07-18 19:36:09.982711673 +0400 | |
38 | +++ squid-3.2.0.18/src/HttpHeader.cc 2012-07-18 19:52:20.551796245 +0400 | |
39 | @@ -147,6 +147,7 @@ | |
40 | {"X-Cache", HDR_X_CACHE, ftStr}, | |
41 | {"X-Cache-Lookup", HDR_X_CACHE_LOOKUP, ftStr}, | |
42 | {"X-Forwarded-For", HDR_X_FORWARDED_FOR, ftStr}, | |
43 | + {"X-Vary-For", HDR_X_VARY_FOR, ftStr}, | |
44 | {"X-Request-URI", HDR_X_REQUEST_URI, ftStr}, | |
45 | {"X-Squid-Error", HDR_X_SQUID_ERROR, ftStr}, | |
46 | #if X_ACCELERATOR_VARY | |
47 | @@ -206,7 +207,8 @@ | |
48 | #endif | |
49 | HDR_SURROGATE_CAPABILITY, | |
50 | HDR_SURROGATE_CONTROL, | |
51 | - HDR_X_FORWARDED_FOR | |
52 | + HDR_X_FORWARDED_FOR, | |
53 | + HDR_X_VARY_FOR | |
54 | }; | |
55 | ||
56 | /* general-headers */ | |
57 | diff -uNrw squid-3.2.0.18/src/HttpHeader.h squid-3.2.0.18/src/HttpHeader.h | |
58 | --- squid-3.2.0.18/src/HttpHeader.h 2012-07-18 19:36:09.978711678 +0400 | |
59 | +++ squid-3.2.0.18/src/HttpHeader.h 2012-07-18 19:36:44.754628494 +0400 | |
60 | @@ -136,6 +136,7 @@ | |
61 | HDR_AUTHENTICATION_INFO, /**< RFC 2617 */ | |
62 | HDR_X_CACHE, /**< Squid custom header */ | |
63 | HDR_X_CACHE_LOOKUP, /**< Squid custom header. temporary hack that became de-facto. TODO remove */ | |
64 | + HDR_X_VARY_FOR, /**< Squid custom header. temporary hack */ | |
65 | HDR_X_FORWARDED_FOR, /**< Squid custom header */ | |
66 | HDR_X_REQUEST_URI, /**< Squid custom header appended if ADD_X_REQUEST_URI is defined */ | |
67 | HDR_X_SQUID_ERROR, /**< Squid custom header on generated error responses */ | |
68 | diff -uNrw squid-3.2.0.18/src/MemObject.cc squid-3.2.0.18/src/MemObject.cc | |
69 | --- squid-3.2.0.18/src/MemObject.cc 2012-07-18 19:36:09.986711701 +0400 | |
70 | +++ squid-3.2.0.18/src/MemObject.cc 2012-07-18 19:43:45.843879163 +0400 | |
71 | @@ -189,6 +189,24 @@ | |
72 | return _reply; | |
73 | } | |
74 | ||
75 | +/* Dirty hack to fill vary_headers field from | |
76 | + * our special HDR_X_VARY_FOR reply header | |
77 | + */ | |
78 | +void | |
79 | +MemObject::fillVaryHeader() | |
80 | +{ | |
81 | + if (_reply && _reply->header.has(HDR_X_VARY_FOR)) | |
82 | + { | |
83 | + debugs(20,3, HERE << "got HDR_X_VARY_FOR: " << _reply->header.getList(HDR_X_VARY_FOR)); | |
84 | + if (! vary_headers) | |
85 | + vary_headers = xstrdup(_reply->header.getList(HDR_X_VARY_FOR).termedBuf()); | |
86 | + else | |
87 | + debugs(20,3, HERE << "vary_headers has already been set up: " << vary_headers); | |
88 | + } | |
89 | + else | |
90 | + debugs(20,3, HERE << "no HDR_X_VARY_FOR present!"); | |
91 | +} | |
92 | + | |
93 | void | |
94 | MemObject::replaceHttpReply(HttpReply *newrep) | |
95 | { | |
96 | diff -uNrw squid-3.2.0.18/src/MemObject.h squid-3.2.0.18/src/MemObject.h | |
97 | --- squid-3.2.0.18/src/MemObject.h 2012-07-18 20:06:23.151879182 +0400 | |
98 | +++ squid-3.2.0.18/src/MemObject.h 2012-07-18 20:08:14.755379555 +0400 | |
99 | @@ -76,6 +76,8 @@ | |
100 | int64_t lowestMemReaderOffset() const; | |
101 | bool readAheadPolicyCanRead() const; | |
102 | void addClient(store_client *); | |
103 | + /* dirty hack to recover vary_headers from the reply */ | |
104 | + void fillVaryHeader(); | |
105 | /* XXX belongs in MemObject::swapout, once swaphdrsz is managed | |
106 | * better | |
107 | */ | |
108 | diff -uNrw squid-3.2.0.18/src/store.cc squid-3.2.0.18/src/store.cc | |
109 | --- squid-3.2.0.18/src/store.cc 2012-07-18 19:36:09.958711514 +0400 | |
110 | +++ squid-3.2.0.18/src/store.cc 2012-07-18 19:55:00.518734384 +0400 | |
111 | @@ -1689,6 +1689,10 @@ | |
112 | mem_obj = hidden_mem_obj; | |
113 | hidden_mem_obj = NULL; | |
114 | mem_obj->resetUrls(aUrl, aLogUrl); | |
115 | + /* XXX: we're probably restoring from the cache, | |
116 | + * so try to recover vary_headers in mem_obj | |
117 | + */ | |
118 | + mem_obj->fillVaryHeader(); | |
119 | return; | |
120 | } | |
121 | ||
122 |