VarState.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_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
18class HttpReply;
19
20/* esi variable replacement logic */
21
22typedef enum {
27
28extern char const * esiBrowsers[];
29
30/* Recursive uses are not supported by design */
31
32struct _query_elem {char *var, *val;};
33
35{
37
38public:
39 ESIVarState(HttpHeader const *hdr, char const *uri);
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();
59
60private:
64
65 struct {
66 unsigned int language:1;
67 unsigned int cookie:1;
68 unsigned int host:1;
69 unsigned int referer:1;
70 unsigned int useragent:1;
72
73public:
74
76 {
77
78 public:
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
92private:
93 void doIt ();
96 std::vector<Variable*> variablesForCleanup;
98};
99
101{
102
103public:
104 void eval (ESIVarState &state, char const *, char const *) const override;
105};
106
108{
109
110public:
111 void eval (ESIVarState &state, char const *, char const *) const override;
112};
113
115{
116
117public:
118 void eval (ESIVarState &state, char const *, char const *) const override;
119};
120
122{
123
124public:
125 ESIVariableQuery(char const *uri);
126 ~ESIVariableQuery() override;
127 void eval (ESIVarState &state, char const *, char const *) const override;
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
142public:
143 void eval (ESIVarState &state, char const *, char const *) const override;
144};
145
147{
148
149public:
150 ~ESIVariableUserAgent() override;
152 void eval (ESIVarState &state, char const *, char const *) const override;
153
154private:
155 static char const * esiUserOs[];
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
unsigned int language
Definition: VarState.h:66
void removeVariable(String const &)
Definition: VarState.cc:267
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
unsigned int referer
Definition: VarState.h:69
HttpHeader hdr
Definition: VarState.h:63
unsigned int cookie
Definition: VarState.h:67
HttpHeader & header()
Definition: VarState.cc:70
void doIt()
Definition: VarState.cc:598
void refererUsed()
Definition: VarState.cc:58
char * extractChar()
Definition: VarState.cc:117
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
unsigned int useragent
Definition: VarState.h:70
ESISegment::Pointer & getOutput()
Definition: VarState.cc:76
CBDATA_CLASS(ESIVarState)
void addVariable(char const *, size_t, Variable *)
Definition: VarState.cc:282
unsigned int host
Definition: VarState.h:68
struct ESIVarState::@62 flags
Variable * defaultVariable
Definition: VarState.h:97
Trie variables
Definition: VarState.h:95
void feedData(const char *buf, size_t len)
Definition: VarState.cc:99
void eval(ESIVarState &state, char const *, char const *) const override
Definition: VarState.cc:374
void eval(ESIVarState &state, char const *, char const *) const override
Definition: VarState.cc:398
void eval(ESIVarState &state, char const *, char const *) const override
Definition: VarState.cc:412
char const * queryString() const
Definition: VarState.cc:82
ESIVariableQuery(char const *uri)
Definition: VarState.cc:163
~ESIVariableQuery() override
Definition: VarState.cc:226
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
void eval(ESIVarState &state, char const *, char const *) const override
Definition: VarState.cc:437
char * query_string
Definition: VarState.h:136
struct _query_elem const * queryVector() const
Definition: VarState.cc:88
void eval(ESIVarState &state, char const *, char const *) const override
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
~ESIVariableUserAgent() override
Definition: VarState.cc:291
esiBrowser_t browser
Definition: VarState.h:167
void eval(ESIVarState &state, char const *, char const *) const override
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