]>
Commit | Line | Data |
---|---|---|
7ede6971 | 1 | /* |
7ede6971 | 2 | * |
3 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
4 | * ---------------------------------------------------------- | |
5 | * | |
6 | * Squid is the result of efforts by numerous individuals from | |
7 | * the Internet community; see the CONTRIBUTORS file for full | |
8 | * details. Many organizations have provided support for Squid's | |
9 | * development; see the SPONSORS file for full details. Squid is | |
10 | * Copyrighted (C) 2001 by the Regents of the University of | |
11 | * California; see the COPYRIGHT file for full details. Squid | |
12 | * incorporates software developed and/or copyrighted by other | |
13 | * sources; see the CREDITS file for full details. | |
14 | * | |
15 | * This program is free software; you can redistribute it and/or modify | |
16 | * it under the terms of the GNU General Public License as published by | |
17 | * the Free Software Foundation; either version 2 of the License, or | |
18 | * (at your option) any later version. | |
26ac0430 | 19 | * |
7ede6971 | 20 | * This program is distributed in the hope that it will be useful, |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | * GNU General Public License for more details. | |
26ac0430 | 24 | * |
7ede6971 | 25 | * You should have received a copy of the GNU General Public License |
26 | * along with this program; if not, write to the Free Software | |
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
28 | * | |
29 | */ | |
7ede6971 | 30 | #ifndef SQUID_HTTPHDRSURROGATECONTROLTARGET_H |
31 | #define SQUID_HTTPHDRSURROGATECONTROLTARGET_H | |
32 | ||
582c2af2 | 33 | #include "defines.h" |
e1f7507e | 34 | #include "dlink.h" |
602d9612 | 35 | #include "MemPool.h" |
e1f7507e | 36 | #include "SquidString.h" |
45a58345 | 37 | #include "typedefs.h" |
7ede6971 | 38 | |
582c2af2 FC |
39 | class StatHist; |
40 | class Packer; | |
41 | class StoreEntry; | |
42 | ||
45a58345 FC |
43 | /** Representation of HTTP Surogate-Control header field targeted directive |
44 | * | |
45 | * \see HttpHdrSc | |
46 | */ | |
7ede6971 | 47 | class HttpHdrScTarget |
48 | { | |
45a58345 FC |
49 | // parsing is done in HttpHdrSc, need to grant them access. |
50 | friend class HttpHdrSc; | |
7ede6971 | 51 | public: |
633b9845 A |
52 | static const int MAX_AGE_UNSET=-1; //max-age is unset |
53 | static const int MAX_STALE_UNSET=0; //max-stale is unset | |
45a58345 FC |
54 | |
55 | HttpHdrScTarget(const char *target_): | |
633b9845 | 56 | mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {} |
45a58345 | 57 | HttpHdrScTarget(const String &target_): |
633b9845 | 58 | mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {} |
45a58345 | 59 | HttpHdrScTarget(const HttpHdrScTarget &t): |
633b9845 A |
60 | mask(t.mask), max_age(t.max_age), max_stale(t.max_stale), |
61 | content_(t.content_), target(t.target) {} | |
45a58345 FC |
62 | |
63 | bool hasNoStore() const {return isSet(SC_NO_STORE); } | |
64 | void noStore(bool v) { setMask(SC_NO_STORE,v); } | |
65 | bool noStore() const { return isSet(SC_NO_STORE); } | |
66 | void clearNoStore() { setMask(SC_NO_STORE, false); } | |
67 | ||
68 | bool hasNoStoreRemote() const {return isSet(SC_NO_STORE_REMOTE); } | |
69 | void noStoreRemote(bool v) { setMask(SC_NO_STORE_REMOTE,v); } | |
70 | bool noStoreRemote() const { return isSet(SC_NO_STORE_REMOTE); } | |
71 | void clearNoStoreRemote() { setMask(SC_NO_STORE_REMOTE, false); } | |
72 | ||
73 | bool hasMaxAge() const { return isSet(SC_MAX_AGE); } | |
74 | void maxAge(int v) { | |
633b9845 A |
75 | if (v >= 0) { //setting |
76 | setMask(SC_MAX_AGE,true); | |
77 | max_age=v; | |
78 | } else { | |
79 | setMask(SC_MAX_AGE,false); | |
80 | max_age=MAX_AGE_UNSET; | |
81 | } | |
45a58345 FC |
82 | } |
83 | int maxAge() const { return max_age; } | |
84 | void clearMaxAge() { setMask(SC_MAX_AGE,false); max_age=MAX_AGE_UNSET; } | |
85 | ||
86 | //max_stale has no associated status-bit | |
87 | bool hasMaxStale() const { return max_stale != MAX_STALE_UNSET; } | |
88 | void maxStale(int v) { max_stale=v; } | |
89 | int maxStale() const { return max_stale; } | |
90 | void clearMaxStale() { max_stale=MAX_STALE_UNSET; } | |
91 | ||
92 | bool hasContent() const { return isSet(SC_CONTENT); } | |
93 | void Content(const String &v) { | |
633b9845 A |
94 | setMask(SC_CONTENT,true); |
95 | content_=v; | |
45a58345 FC |
96 | } |
97 | String content() const { return content_; } | |
98 | void clearContent() { setMask(SC_CONTENT,false); content_.clean(); } | |
99 | ||
100 | bool hasTarget() const { return target.size() != 0; } | |
101 | String Target() const { return target; } | |
102 | ||
103 | void mergeWith(const HttpHdrScTarget * new_sc); | |
104 | void packInto (Packer *p) const; | |
105 | void updateStats(StatHist *) const; | |
106 | ||
7ede6971 | 107 | MEMPROXY_CLASS(HttpHdrScTarget); |
45a58345 FC |
108 | private: |
109 | bool isSet(http_hdr_sc_type id) const { | |
110 | assert (id >= SC_NO_STORE && id < SC_ENUM_END); | |
111 | return EBIT_TEST(mask,id); | |
112 | } | |
113 | ||
114 | void setMask(http_hdr_sc_type id, bool newval) { | |
115 | if (newval) EBIT_SET(mask,id); | |
116 | else EBIT_CLR(mask,id); | |
117 | } | |
118 | ||
7ede6971 | 119 | int mask; |
120 | int max_age; | |
121 | int max_stale; | |
45a58345 | 122 | String content_; |
30abd221 | 123 | String target; |
45a58345 | 124 | dlink_node node; |
7ede6971 | 125 | }; |
126 | ||
127 | MEMPROXY_CLASS_INLINE(HttpHdrScTarget); | |
128 | ||
8a648e8d | 129 | void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count); |
7ede6971 | 130 | |
131 | #endif /* SQUID_HTTPHDRSURROGATECONTROLTARGET_H */ |