HttpHdrScTarget.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_HTTPHDRSURROGATECONTROLTARGET_H
10 #define SQUID_HTTPHDRSURROGATECONTROLTARGET_H
11 
12 #include "defines.h" //for bit mask operations
13 #include "HttpHdrSc.h"
14 
15 class Packable;
16 class StatHist;
17 class StoreEntry;
18 
24 {
26 
27  // parsing is done in HttpHdrSc, need to grant them access.
28  friend class HttpHdrSc;
29 public:
30  static const int MAX_AGE_UNSET=-1; //max-age is unset
31  static const int MAX_STALE_UNSET=0; //max-stale is unset
32 
33  HttpHdrScTarget(const char *target_):
35  HttpHdrScTarget(const String &target_):
39  content_(t.content_), target(t.target) {}
40 
41  bool hasNoStore() const {return isSet(SC_NO_STORE); }
42  void noStore(bool v) { setMask(SC_NO_STORE,v); }
43  bool noStore() const { return isSet(SC_NO_STORE); }
44  void clearNoStore() { setMask(SC_NO_STORE, false); }
45 
46  bool hasNoStoreRemote() const {return isSet(SC_NO_STORE_REMOTE); }
48  bool noStoreRemote() const { return isSet(SC_NO_STORE_REMOTE); }
50 
51  bool hasMaxAge() const { return isSet(SC_MAX_AGE); }
52  void maxAge(int v) {
53  if (v >= 0) { //setting
54  setMask(SC_MAX_AGE,true);
55  max_age=v;
56  } else {
57  setMask(SC_MAX_AGE,false);
59  }
60  }
61  int maxAge() const { return max_age; }
63 
64  //max_stale has no associated status-bit
65  bool hasMaxStale() const { return max_stale != MAX_STALE_UNSET; }
66  void maxStale(int v) { max_stale=v; }
67  int maxStale() const { return max_stale; }
69 
70  bool hasContent() const { return isSet(SC_CONTENT); }
71  void Content(const String &v) {
72  setMask(SC_CONTENT,true);
73  content_=v;
74  }
75  String content() const { return content_; }
77 
78  bool hasTarget() const { return target.size() != 0; }
79  String Target() const { return target; }
80 
81  void mergeWith(const HttpHdrScTarget * new_sc);
82  void packInto(Packable *p) const;
83  void updateStats(StatHist *) const;
84 
85 private:
86  bool isSet(http_hdr_sc_type id) const {
87  assert (id >= SC_NO_STORE && id < SC_ENUM_END);
88  return EBIT_TEST(mask,id);
89  }
90 
91  void setMask(http_hdr_sc_type id, bool newval) {
92  if (newval) EBIT_SET(mask,id);
93  else EBIT_CLR(mask,id);
94  }
95 
96  int mask;
97  int max_age;
98  int max_stale;
102 };
103 
104 void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
105 
106 #endif /* SQUID_HTTPHDRSURROGATECONTROLTARGET_H */
107 
String Target() const
void packInto(Packable *p) const
Definition: HttpHdrSc.cc:221
void maxStale(int v)
bool hasNoStore() const
#define assert(EX)
Definition: assert.h:17
bool noStore() const
void noStore(bool v)
void Content(const String &v)
bool noStoreRemote() const
char * p
Definition: membanger.c:43
size_type size() const
Definition: SquidString.h:71
void clearNoStoreRemote()
bool hasTarget() const
bool hasMaxStale() const
String content() const
#define EBIT_CLR(flag, bit)
Definition: defines.h:106
void httpHdrScTargetStatDumper(StoreEntry *sentry, int idx, double val, double size, int count)
Definition: HttpHdrSc.cc:288
HttpHdrScTarget(const HttpHdrScTarget &t)
static const int MAX_STALE_UNSET
bool hasMaxAge() const
static const int MAX_AGE_UNSET
#define EBIT_SET(flag, bit)
Definition: defines.h:105
void maxAge(int v)
bool isSet(http_hdr_sc_type id) const
HttpHdrScTarget(const char *target_)
HttpHdrScTarget(const String &target_)
bool hasNoStoreRemote() const
int maxStale() const
void setMask(http_hdr_sc_type id, bool newval)
void updateStats(StatHist *) const
void clean()
Definition: String.cc:125
MEMPROXY_CLASS(HttpHdrScTarget)
http_hdr_sc_type
Definition: HttpHdrSc.h:21
int maxAge() const
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
bool hasContent() const
int size
Definition: ModDevPoll.cc:77
void mergeWith(const HttpHdrScTarget *new_sc)
void noStoreRemote(bool v)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors