]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Context.h
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_ESICONTEXT_H
10 #define SQUID_ESICONTEXT_H
12 #include "clientStream.h"
14 #include "esi/Element.h"
15 #include "esi/Parser.h"
16 #include "http/StatusCode.h"
19 class ClientHttpRequest
;
23 class ESIContext
: public esiTreeParent
, public ESIParserClient
25 CBDATA_CLASS(ESIContext
);
28 typedef RefCount
<ESIContext
> Pointer
;
33 errorstatus(Http::scNone
),
40 cachedASTInUse(false),
43 memset(&flags
, 0, sizeof(flags
));
55 /* when esi processing completes */
56 void provideData(ESISegment::Pointer
, ESIElement
*source
);
57 void fail (ESIElement
*source
, char const*anError
= NULL
);
62 void setErrorMessage(char const *);
64 void addStackElement (ESIElement::Pointer element
);
65 void addLiteral (const char *s
, int len
);
67 void finishChildren ();
69 clientStreamNode
*thisNode
; /* our stream node */
70 /* the request we are processing. HMM: cbdataReferencing this will result
71 * in a circular reference, so we don't. Note: we are automatically freed
72 * when it is, so thats ok. */
73 ClientHttpRequest
*http
;
80 /* an error has occured, send full body replies
81 * regardless. Note that we don't fail midstream
82 * because we buffer until we can not fail
86 int finishedtemplate
:1; /* we've read the entire template */
87 int clientwantsdata
:1; /* we need to satisfy a read request */
88 int kicked
:1; /* note on reentering the kick routine */
89 int detached
:1; /* our downstream has detached */
92 err_type errorpage
; /* if we error what page to use */
93 Http::StatusCode errorstatus
; /* if we error, what code to return */
94 char *errormessage
; /* error to pass to error page */
95 HttpReply
*rep
; /* buffered until we pass data downstream */
96 ESISegment::Pointer buffered
; /* unprocessed data - for whatever reason */
97 ESISegment::Pointer incoming
;
98 /* processed data we are waiting to send, or for
99 * potential errors to be resolved
101 ESISegment::Pointer outbound
;
102 ESISegment::Pointer outboundtail
; /* our write segment */
103 /* the offset to the next character to send -
104 * non zero if we haven't sent the entire segment
107 size_t outbound_offset
;
108 int64_t readpos
; /* the logical position we are reading from */
109 int64_t pos
; /* the logical position of outbound_offset in the data stream */
115 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
116 int stackdepth
; /* self explanatory */
117 ESIParser::Pointer theParser
;
118 ESIElement::Pointer
top();
119 void init (ESIParserClient
*);
122 void freeResources();
124 int parsing
:1; /* libexpat is not reentrant on the same context */
130 parserState
; /* todo factor this off somewhere else; */
131 ESIVarState
*varState
;
132 ESIElement::Pointer tree
;
135 RefCount
<ESIContext
> cbdataLocker
;
136 bool failed() const {return flags
.error
!= 0;}
142 void freeResources();
143 void fixupOutboundTail();
147 void appendOutboundData(ESISegment::Pointer theData
);
148 esiProcessResult_t
process ();
150 void parseOneBuffer();
151 void updateCachedAST();
152 bool hasCachedAST() const;
154 virtual void start(const char *el
, const char **attr
, size_t attrCount
);
155 virtual void end(const char *el
);
156 virtual void parserDefault (const char *s
, int len
);
157 virtual void parserComment (const char *s
);
161 #endif /* SQUID_ESICONTEXT_H */