]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpHdrScTarget.h
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_HTTPHDRSURROGATECONTROLTARGET_H
10 #define SQUID_HTTPHDRSURROGATECONTROLTARGET_H
12 #include "defines.h" //for bit mask operations
13 #include "http/forward.h"
14 #include "SquidString.h"
20 /** Representation of HTTP Surogate-Control header field targeted directive
26 // parsing is done in HttpHdrSc, need to grant them access.
27 friend class HttpHdrSc
;
29 static const int MAX_AGE_UNSET
=-1; //max-age is unset
30 static const int MAX_STALE_UNSET
=0; //max-stale is unset
32 explicit HttpHdrScTarget(const char *aTarget
): target(aTarget
) {}
33 explicit HttpHdrScTarget(const String
&aTarget
): target(aTarget
) {}
34 explicit HttpHdrScTarget(const HttpHdrScTarget
&) = delete; // avoid accidental string copies
35 HttpHdrScTarget
&operator =(const HttpHdrScTarget
&) = delete; // avoid accidental string copies
37 bool hasNoStore() const {return isSet(SC_NO_STORE
); }
38 void noStore(bool v
) { setMask(SC_NO_STORE
,v
); }
39 bool noStore() const { return isSet(SC_NO_STORE
); }
40 void clearNoStore() { setMask(SC_NO_STORE
, false); }
42 bool hasNoStoreRemote() const {return isSet(SC_NO_STORE_REMOTE
); }
43 void noStoreRemote(bool v
) { setMask(SC_NO_STORE_REMOTE
,v
); }
44 bool noStoreRemote() const { return isSet(SC_NO_STORE_REMOTE
); }
45 void clearNoStoreRemote() { setMask(SC_NO_STORE_REMOTE
, false); }
47 bool hasMaxAge() const { return isSet(SC_MAX_AGE
); }
49 if (v
>= 0) { //setting
50 setMask(SC_MAX_AGE
,true);
53 setMask(SC_MAX_AGE
,false);
54 max_age
=MAX_AGE_UNSET
;
57 int maxAge() const { return max_age
; }
58 void clearMaxAge() { setMask(SC_MAX_AGE
,false); max_age
=MAX_AGE_UNSET
; }
60 //max_stale has no associated status-bit
61 bool hasMaxStale() const { return max_stale
!= MAX_STALE_UNSET
; }
62 void maxStale(int v
) { max_stale
=v
; }
63 int maxStale() const { return max_stale
; }
64 void clearMaxStale() { max_stale
=MAX_STALE_UNSET
; }
66 bool hasContent() const { return isSet(SC_CONTENT
); }
67 void Content(const String
&v
) {
68 setMask(SC_CONTENT
,true);
71 String
content() const { return content_
; }
72 void clearContent() { setMask(SC_CONTENT
,false); content_
.clean(); }
74 bool hasTarget() const { return target
.size() != 0; }
75 String
Target() const { return target
; }
77 void mergeWith(const HttpHdrScTarget
* new_sc
);
78 void packInto(Packable
*p
) const;
79 void updateStats(StatHist
*) const;
82 bool isSet(http_hdr_sc_type id
) const {
83 assert (id
>= SC_NO_STORE
&& id
< SC_ENUM_END
);
84 return EBIT_TEST(mask
,id
);
87 void setMask(http_hdr_sc_type id
, bool newval
) {
88 if (newval
) EBIT_SET(mask
,id
);
89 else EBIT_CLR(mask
,id
);
93 int max_age
= MAX_AGE_UNSET
;
94 int max_stale
= MAX_STALE_UNSET
;
99 void httpHdrScTargetStatDumper(StoreEntry
* sentry
, int idx
, double val
, double size
, int count
);
101 #endif /* SQUID_HTTPHDRSURROGATECONTROLTARGET_H */