Context.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_ESICONTEXT_H
10 #define SQUID_ESICONTEXT_H
11 
12 #include "clientStream.h"
13 #include "err_type.h"
14 #include "esi/Element.h"
15 #include "esi/Parser.h"
16 #include "http/forward.h"
17 #include "http/StatusCode.h"
18 
19 class ESIVarState;
20 class ClientHttpRequest;
21 
22 /* ESIContext */
23 
25 {
27 
28 public:
31  thisNode(NULL),
32  http(NULL),
34  errorstatus(Http::scNone),
36  rep(NULL),
37  outbound_offset(0),
38  readpos(0),
39  pos(0),
40  varState(NULL),
42  reading_(true),
43  processing(false) {
44  memset(&flags, 0, sizeof(flags));
45  }
46 
47  ~ESIContext();
48 
49  enum esiKick_t {
54  };
55 
56  /* when esi processing completes */
58  void fail (ESIElement *source, char const*anError = NULL);
59  void startRead();
60  void finishRead();
61  bool reading() const;
62  void setError();
63  void setErrorMessage(char const *);
64 
65  void addStackElement (ESIElement::Pointer element);
66  void addLiteral (const char *s, int len);
67 
68  void finishChildren ();
69 
70  clientStreamNode *thisNode; /* our stream node */
71  /* the request we are processing. HMM: cbdataReferencing this will result
72  * in a circular reference, so we don't. Note: we are automatically freed
73  * when it is, so thats ok. */
75 
76  struct {
77  int passthrough:1;
78  int oktosend:1;
79  int finished:1;
80 
81  /* an error has occured, send full body replies
82  * regardless. Note that we don't fail midstream
83  * because we buffer until we can not fail
84  */
85  int error:1;
86 
87  int finishedtemplate:1; /* we've read the entire template */
88  int clientwantsdata:1; /* we need to satisfy a read request */
89  int kicked:1; /* note on reentering the kick routine */
90  int detached:1; /* our downstream has detached */
91  } flags;
92 
93  err_type errorpage; /* if we error what page to use */
94  Http::StatusCode errorstatus; /* if we error, what code to return */
95  char *errormessage; /* error to pass to error page */
96  HttpReplyPointer rep; /* buffered until we pass data downstream */
97  ESISegment::Pointer buffered; /* unprocessed data - for whatever reason */
99  /* processed data we are waiting to send, or for
100  * potential errors to be resolved
101  */
103  ESISegment::Pointer outboundtail; /* our write segment */
104  /* the offset to the next character to send -
105  * non zero if we haven't sent the entire segment
106  * for some reason
107  */
109  int64_t readpos; /* the logical position we are reading from */
110  int64_t pos; /* the logical position of outbound_offset in the data stream */
111 
113  {
114 
115  public:
116  ESIElement::Pointer stack[10]; /* a stack of esi elements that are open */
117  int stackdepth; /* self explanatory */
120  void init (ESIParserClient *);
121  bool inited() const;
122  ParserState();
123  void freeResources();
124  void popAll();
125  int parsing:1; /* libexpat is not reentrant on the same context */
126 
127  private:
128  bool inited_;
129  }
130 
131  parserState; /* todo factor this off somewhere else; */
134 
135  esiKick_t kick ();
137  bool failed() const {return flags.error != 0;}
138 
140 
141 private:
142  void fail ();
143  void freeResources();
144  void fixupOutboundTail();
145  void trimBlanks();
146  size_t send ();
147  bool reading_;
150  void parse();
151  void parseOneBuffer();
152  void updateCachedAST();
153  bool hasCachedAST() const;
154  void getCachedAST();
155  virtual void start(const char *el, const char **attr, size_t attrCount);
156  virtual void end(const char *el);
157  virtual void parserDefault (const char *s, int len);
158  virtual void parserComment (const char *s);
160 };
161 
162 #endif /* SQUID_ESICONTEXT_H */
163 
size_t outbound_offset
Definition: Context.h:108
bool inited() const
Definition: Esi.cc:924
HttpReplyPointer rep
Definition: Context.h:96
int passthrough
Definition: Context.h:77
void finishRead()
Definition: Esi.cc:225
ESIElement::Pointer stack[10]
Definition: Context.h:116
void fail()
Definition: Esi.cc:1409
ESIElement::Pointer tree
Definition: Context.h:133
ESIParser::Pointer theParser
Definition: Context.h:118
RefCount< ESIContext > cbdataLocker
Definition: Context.h:136
virtual void parserComment(const char *s)
Definition: Esi.cc:1139
void fixupOutboundTail()
Definition: Esi.cc:290
esiProcessResult_t
Definition: Element.h:16
int clientwantsdata
Definition: Context.h:88
bool reading() const
Definition: Esi.cc:231
bool processing
Definition: Context.h:159
StatusCode
Definition: StatusCode.h:20
ESISegment::Pointer outboundtail
Definition: Context.h:103
void provideData(ESISegment::Pointer, ESIElement *source)
Definition: Esi.cc:267
#define true
Definition: GnuRegex.c:234
ESISegment::Pointer outbound
Definition: Context.h:102
void updateCachedAST()
Definition: Context.cc:24
void parseOneBuffer()
Definition: Esi.cc:1208
int detached
Definition: Context.h:90
ESIElement::Pointer top()
Definition: Esi.cc:912
void setErrorMessage(char const *)
Definition: Context.cc:86
char * errormessage
Definition: Context.h:95
int64_t pos
Definition: Context.h:110
void init(ESIParserClient *)
Definition: Esi.cc:1201
bool hasCachedAST() const
Definition: Context.cc:52
esiKick_t kick()
Definition: Esi.cc:299
int error
Definition: Context.h:85
int finishedtemplate
Definition: Context.h:87
ESISegment::Pointer buffered
Definition: Context.h:97
int finished
Definition: Context.h:79
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
bool cachedASTInUse
Definition: Context.h:139
size_t send()
Definition: Esi.cc:535
virtual void start(const char *el, const char **attr, size_t attrCount)
Definition: Esi.cc:948
bool reading_
Definition: Context.h:147
void parse()
Definition: Esi.cc:1240
void addLiteral(const char *s, int len)
Definition: Esi.cc:1185
int oktosend
Definition: Context.h:78
ClientHttpRequest * http
Definition: Context.h:74
clientStreamNode * thisNode
Definition: Context.h:70
CBDATA_CLASS(ESIContext)
int kicked
Definition: Context.h:89
virtual void end(const char *el)
Definition: Esi.cc:1076
void appendOutboundData(ESISegment::Pointer theData)
Definition: Esi.cc:252
ESISegment::Pointer incoming
Definition: Context.h:98
void setError()
Definition: Esi.cc:244
void getCachedAST()
Definition: Context.cc:69
bool failed() const
Definition: Context.h:137
void freeResources()
Definition: Esi.cc:1384
RefCount< ESIContext > Pointer
Definition: Context.h:29
virtual void parserDefault(const char *s, int len)
Definition: Esi.cc:1129
void addStackElement(ESIElement::Pointer element)
Definition: Esi.cc:930
int64_t readpos
Definition: Context.h:109
~ESIContext()
Definition: Esi.cc:821
Http::StatusCode errorstatus
Definition: Context.h:94
err_type errorpage
Definition: Context.h:93
esiProcessResult_t process()
Definition: Esi.cc:1272
ESIVarState * varState
Definition: Context.h:132
ESIContext()
Definition: Context.h:30
void startRead()
Definition: Esi.cc:219
class ESIContext::ParserState parserState
struct ESIContext::@61 flags
void finishChildren()
Definition: Esi.cc:633
#define NULL
Definition: types.h:166
#define false
Definition: GnuRegex.c:233
err_type
Definition: err_type.h:12
void trimBlanks()
Definition: Esi.cc:517

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors