]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Context.h
2 * Copyright (C) 1996-2017 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/forward.h"
17 #include "http/StatusCode.h"
20 class ClientHttpRequest
;
24 class ESIContext
: public esiTreeParent
, public ESIParserClient
26 CBDATA_CLASS(ESIContext
);
29 typedef RefCount
<ESIContext
> Pointer
;
34 errorstatus(Http::scNone
),
41 cachedASTInUse(false),
44 memset(&flags
, 0, sizeof(flags
));
56 /* when esi processing completes */
57 void provideData(ESISegment::Pointer
, ESIElement
*source
);
58 void fail (ESIElement
*source
, char const*anError
= NULL
);
63 void setErrorMessage(char const *);
65 void addStackElement (ESIElement::Pointer element
);
66 void addLiteral (const char *s
, int len
);
68 void finishChildren ();
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. */
74 ClientHttpRequest
*http
;
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
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 */
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 */
98 ESISegment::Pointer incoming
;
99 /* processed data we are waiting to send, or for
100 * potential errors to be resolved
102 ESISegment::Pointer outbound
;
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
108 size_t outbound_offset
;
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 */
116 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
117 int stackdepth
; /* self explanatory */
118 ESIParser::Pointer theParser
;
119 ESIElement::Pointer
top();
120 void init (ESIParserClient
*);
123 void freeResources();
125 int parsing
:1; /* libexpat is not reentrant on the same context */
131 parserState
; /* todo factor this off somewhere else; */
132 ESIVarState
*varState
;
133 ESIElement::Pointer tree
;
136 RefCount
<ESIContext
> cbdataLocker
;
137 bool failed() const {return flags
.error
!= 0;}
143 void freeResources();
144 void fixupOutboundTail();
148 void appendOutboundData(ESISegment::Pointer theData
);
149 esiProcessResult_t
process ();
151 void parseOneBuffer();
152 void updateCachedAST();
153 bool hasCachedAST() const;
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
);
162 #endif /* SQUID_ESICONTEXT_H */