VarState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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_ESIVARSTATE_H
10 #define SQUID_ESIVARSTATE_H
11 
12 #include "esi/Segment.h"
13 #include "HttpHeader.h"
14 #include "libTrie/Trie.h"
15 
16 #include <vector>
17 
18 class HttpReply;
19 
20 /* esi variable replacement logic */
21 
22 typedef enum {
27 
28 extern char const * esiBrowsers[];
29 
30 /* Recursive uses are not supported by design */
31 
32 struct _query_elem {char *var, *val;};
33 
35 {
37 
38 public:
39  ESIVarState(HttpHeader const *hdr, char const *uri);
40  ~ESIVarState();
41 
43  char *extractChar();
44  void feedData (const char *buf, size_t len);
45  void buildVary (HttpReply *rep);
46 
47  class Variable;
48  void addVariable (char const *, size_t, Variable *);
49  void removeVariable (String const &);
50 
51  /* For Variables */
52  void cookieUsed();
53  void hostUsed();
54  void languageUsed();
55  void refererUsed();
56  void useragentUsed();
58  HttpHeader &header();
59 
60 private:
64 
65  struct {
66  int language:1;
67  int cookie:1;
68  int host:1;
69  int referer:1;
70  int useragent:1;
71  } flags;
72 
73 public:
74 
75  class Variable
76  {
77 
78  public:
79  Variable () {}
80 
81  virtual ~Variable() {}
82 
83  /* prevent synthetics */
84  Variable (Variable const &) {}
85 
87  virtual void eval (ESIVarState &state, char const *, char const *) const;
88  };
89 
90  Variable* GetVar(char const *s, int len);
91 
92 private:
93  void doIt ();
95  Trie variables;
96  std::vector<Variable*> variablesForCleanup;
98 };
99 
101 {
102 
103 public:
104  virtual void eval (ESIVarState &state, char const *, char const *) const;
105 };
106 
108 {
109 
110 public:
111  virtual void eval (ESIVarState &state, char const *, char const *) const;
112 };
113 
115 {
116 
117 public:
118  virtual void eval (ESIVarState &state, char const *, char const *) const;
119 };
120 
122 {
123 
124 public:
125  ESIVariableQuery(char const *uri);
127  virtual void eval (ESIVarState &state, char const *, char const *) const;
128  char const *queryString() const;
129 
130  struct _query_elem const *queryVector() const;
131  size_t const &queryElements() const;
132 
134  size_t query_sz;
137 };
138 
140 {
141 
142 public:
143  virtual void eval (ESIVarState &state, char const *, char const *) const;
144 };
145 
147 {
148 
149 public:
152  virtual void eval (ESIVarState &state, char const *, char const *) const;
153 
154 private:
155  static char const * esiUserOs[];
156  enum esiUserOs_t {
161  };
162  esiUserOs_t identifyOs(char const *) const;
163  char const *browserVersion() const {return browserversion;}
164 
165  char *getProductVersion (char const *s);
169 };
170 
171 #endif /* SQUID_ESIVARSTATE_H */
172 
char const * esiBrowsers[]
Definition: VarState.cc:23
esiBrowser_t
Definition: VarState.h:22
@ ESI_BROWSER_MOZILLA
Definition: VarState.h:24
@ ESI_BROWSER_OTHER
Definition: VarState.h:25
@ ESI_BROWSER_MSIE
Definition: VarState.h:23
Variable(Variable const &)
Definition: VarState.h:84
virtual ~Variable()
Definition: VarState.h:81
Variable & operator=(Variable const &)
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:31
struct ESIVarState::@65 flags
int useragent
Definition: VarState.h:70
void removeVariable(String const &)
Definition: VarState.cc:267
int host
Definition: VarState.h:68
ESISegment::Pointer input
Definition: VarState.h:61
void useragentUsed()
Definition: VarState.cc:64
Variable * GetVar(char const *s, int len)
Definition: VarState.cc:585
void cookieUsed()
Definition: VarState.cc:46
HttpHeader hdr
Definition: VarState.h:63
HttpHeader & header()
Definition: VarState.cc:70
int cookie
Definition: VarState.h:67
void doIt()
Definition: VarState.cc:598
void refererUsed()
Definition: VarState.cc:58
char * extractChar()
Definition: VarState.cc:117
int referer
Definition: VarState.h:69
ESISegment::Pointer output
Definition: VarState.h:62
void setupUserAgent()
void languageUsed()
Definition: VarState.cc:52
void buildVary(HttpReply *rep)
Definition: VarState.cc:810
void hostUsed()
Definition: VarState.cc:40
ESIVarState(HttpHeader const *hdr, char const *uri)
Definition: VarState.cc:242
std::vector< Variable * > variablesForCleanup
Definition: VarState.h:96
ESISegment::Pointer extractList()
Definition: VarState.cc:107
ESISegment::Pointer & getOutput()
Definition: VarState.cc:76
CBDATA_CLASS(ESIVarState)
void addVariable(char const *, size_t, Variable *)
Definition: VarState.cc:282
int language
Definition: VarState.h:66
Variable * defaultVariable
Definition: VarState.h:97
Trie variables
Definition: VarState.h:95
void feedData(const char *buf, size_t len)
Definition: VarState.cc:99
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:374
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:398
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:412
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:437
char const * queryString() const
Definition: VarState.cc:82
ESIVariableQuery(char const *uri)
Definition: VarState.cc:163
size_t query_sz
Definition: VarState.h:134
size_t query_elements
Definition: VarState.h:135
size_t const & queryElements() const
Definition: VarState.cc:93
struct _query_elem * query
Definition: VarState.h:133
char * query_string
Definition: VarState.h:136
struct _query_elem const * queryVector() const
Definition: VarState.cc:88
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:461
static char const * esiUserOs[]
Definition: VarState.h:155
ESIVariableUserAgent(ESIVarState &state)
Definition: VarState.cc:296
char const * browserVersion() const
Definition: VarState.h:163
esiUserOs_t identifyOs(char const *) const
Definition: VarState.cc:358
char * getProductVersion(char const *s)
Definition: VarState.cc:149
esiBrowser_t browser
Definition: VarState.h:167
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:475
esiUserOs_t UserOs
Definition: VarState.h:166
char * val
Definition: VarState.h:32
char * var
Definition: VarState.h:32

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors