HttpHdrScTarget.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 "http/forward.h"
14#include "SquidString.h"
15
16class Packable;
17class StatHist;
18class StoreEntry;
19
25{
26 // parsing is done in HttpHdrSc, need to grant them access.
27 friend class HttpHdrSc;
28public:
29 static const int MAX_AGE_UNSET=-1; //max-age is unset
30 static const int MAX_STALE_UNSET=0; //max-stale is unset
31
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
36
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); }
41
42 bool hasNoStoreRemote() const {return isSet(SC_NO_STORE_REMOTE); }
44 bool noStoreRemote() const { return isSet(SC_NO_STORE_REMOTE); }
46
47 bool hasMaxAge() const { return isSet(SC_MAX_AGE); }
48 void maxAge(int v) {
49 if (v >= 0) { //setting
50 setMask(SC_MAX_AGE,true);
51 max_age=v;
52 } else {
53 setMask(SC_MAX_AGE,false);
55 }
56 }
57 int maxAge() const { return max_age; }
59
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; }
65
66 bool hasContent() const { return isSet(SC_CONTENT); }
67 void Content(const String &v) {
68 setMask(SC_CONTENT,true);
69 content_=v;
70 }
71 String content() const { return content_; }
73
74 bool hasTarget() const { return target.size() != 0; }
75 String Target() const { return target; }
76
77 void mergeWith(const HttpHdrScTarget * new_sc);
78 void packInto(Packable *p) const;
79 void updateStats(StatHist *) const;
80
81private:
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);
85 }
86
87 void setMask(http_hdr_sc_type id, bool newval) {
88 if (newval) EBIT_SET(mask,id);
89 else EBIT_CLR(mask,id);
90 }
91
92 int mask = 0;
97};
98
99void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
100
101#endif /* SQUID_HTTPHDRSURROGATECONTROLTARGET_H */
102
void httpHdrScTargetStatDumper(StoreEntry *sentry, int idx, double val, double size, int count)
Definition: HttpHdrSc.cc:257
int size
Definition: ModDevPoll.cc:75
#define assert(EX)
Definition: assert.h:17
bool noStore() const
void maxAge(int v)
void noStore(bool v)
String content() const
bool isSet(http_hdr_sc_type id) const
bool noStoreRemote() const
void mergeWith(const HttpHdrScTarget *new_sc)
void updateStats(StatHist *) const
bool hasTarget() const
void setMask(http_hdr_sc_type id, bool newval)
bool hasMaxAge() const
static const int MAX_STALE_UNSET
bool hasNoStoreRemote() const
HttpHdrScTarget(const String &aTarget)
HttpHdrScTarget & operator=(const HttpHdrScTarget &)=delete
bool hasContent() const
static const int MAX_AGE_UNSET
int maxAge() const
int maxStale() const
void clearNoStoreRemote()
bool hasNoStore() const
void packInto(Packable *p) const
XXX: this function should be in HttpHdrScTarget.cc.
Definition: HttpHdrSc.cc:198
HttpHdrScTarget(const HttpHdrScTarget &)=delete
HttpHdrScTarget(const char *aTarget)
void noStoreRemote(bool v)
void Content(const String &v)
bool hasMaxStale() const
void maxStale(int v)
String Target() const
void clean()
Definition: String.cc:103
size_type size() const
Definition: SquidString.h:73
#define EBIT_CLR(flag, bit)
Definition: defines.h:68
#define EBIT_SET(flag, bit)
Definition: defines.h:67
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
http_hdr_sc_type
Definition: forward.h:31
@ SC_CONTENT
Definition: forward.h:35
@ SC_NO_STORE
Definition: forward.h:32
@ SC_NO_STORE_REMOTE
Definition: forward.h:33
@ SC_ENUM_END
Definition: forward.h:37
@ SC_MAX_AGE
Definition: forward.h:34

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors