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