VarState.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_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 {
26 } esiBrowser_t;
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 
86  Variable &operator= (Variable const &);
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 ();
94  void setupUserAgent();
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 
virtual ~Variable()
Definition: VarState.h:81
ESISegment::Pointer input
Definition: VarState.h:61
size_t query_elements
Definition: VarState.h:135
Variable & operator=(Variable const &)
int useragent
Definition: VarState.h:70
void buildVary(HttpReply *rep)
Definition: VarState.cc:810
Trie variables
Definition: VarState.h:95
ESIVarState(HttpHeader const *hdr, char const *uri)
Definition: VarState.cc:242
esiUserOs_t UserOs
Definition: VarState.h:166
size_t const & queryElements() const
Definition: VarState.cc:93
void languageUsed()
Definition: VarState.cc:52
char const * esiBrowsers[]
Definition: VarState.cc:23
CBDATA_CLASS(ESIVarState)
HttpHeader hdr
Definition: VarState.h:63
char * var
Definition: VarState.h:32
ESIVariableUserAgent(ESIVarState &state)
Definition: VarState.cc:296
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:437
HttpHeader & header()
Definition: VarState.cc:70
char const * browserVersion() const
Definition: VarState.h:163
char * extractChar()
Definition: VarState.cc:117
Variable(Variable const &)
Definition: VarState.h:84
void addVariable(char const *, size_t, Variable *)
Definition: VarState.cc:282
char * query_string
Definition: VarState.h:136
int cookie
Definition: VarState.h:67
struct _query_elem const * queryVector() const
Definition: VarState.cc:88
char * val
Definition: VarState.h:32
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:31
void refererUsed()
Definition: VarState.cc:58
std::vector< Variable * > variablesForCleanup
Definition: VarState.h:96
int language
Definition: VarState.h:66
static char const * esiUserOs[]
Definition: VarState.h:155
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:398
void cookieUsed()
Definition: VarState.cc:46
char * getProductVersion(char const *s)
Definition: VarState.cc:149
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
ESIVariableQuery(char const *uri)
Definition: VarState.cc:163
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:374
Variable * defaultVariable
Definition: VarState.h:97
void setupUserAgent()
ESISegment::Pointer & getOutput()
Definition: VarState.cc:76
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:461
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:412
ESISegment::Pointer output
Definition: VarState.h:62
void useragentUsed()
Definition: VarState.cc:64
esiUserOs_t identifyOs(char const *) const
Definition: VarState.cc:358
esiBrowser_t
Definition: VarState.h:22
void doIt()
Definition: VarState.cc:598
int referer
Definition: VarState.h:69
char const * queryString() const
Definition: VarState.cc:82
void hostUsed()
Definition: VarState.cc:40
void removeVariable(String const &)
Definition: VarState.cc:267
virtual void eval(ESIVarState &state, char const *, char const *) const
Definition: VarState.cc:475
struct _query_elem * query
Definition: VarState.h:133
esiBrowser_t browser
Definition: VarState.h:167
ESISegment::Pointer extractList()
Definition: VarState.cc:107
Variable * GetVar(char const *s, int len)
Definition: VarState.cc:585
struct ESIVarState::@67 flags
size_t query_sz
Definition: VarState.h:134
int host
Definition: VarState.h:68

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors