VarState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
42  ESISegment::Pointer extractList();
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();
57  ESISegment::Pointer &getOutput();
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);
126  ~ESIVariableQuery();
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 {
160  ESI_OS_OTHER
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
int useragent
Definition: VarState.h:70
Trie variables
Definition: VarState.h:95
esiUserOs_t UserOs
Definition: VarState.h:166
char const * esiBrowsers[]
Definition: VarState.cc:23
HttpHeader hdr
Definition: VarState.h:63
char * var
Definition: VarState.h:32
Variable(Variable const &)
Definition: VarState.h:84
char * query_string
Definition: VarState.h:136
int cookie
Definition: VarState.h:67
char * val
Definition: VarState.h:32
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
std::vector< Variable * > variablesForCleanup
Definition: VarState.h:96
int language
Definition: VarState.h:66
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
Variable * defaultVariable
Definition: VarState.h:97
ESISegment::Pointer output
Definition: VarState.h:62
esiBrowser_t
Definition: VarState.h:22
char const * browserVersion() const
Definition: VarState.h:163
int referer
Definition: VarState.h:69
struct _query_elem * query
Definition: VarState.h:133
esiBrowser_t browser
Definition: VarState.h:167
size_t query_sz
Definition: VarState.h:134
int host
Definition: VarState.h:68

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors