]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Context.h
3 * SQUID Web Proxy Cache http://www.squid-cache.org/
4 * ----------------------------------------------------------
6 * Squid is the result of efforts by numerous individuals from
7 * the Internet community; see the CONTRIBUTORS file for full
8 * details. Many organizations have provided support for Squid's
9 * development; see the SPONSORS file for full details. Squid is
10 * Copyrighted (C) 2001 by the Regents of the University of
11 * California; see the COPYRIGHT file for full details. Squid
12 * incorporates software developed and/or copyrighted by other
13 * sources; see the CREDITS file for full details.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
29 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
32 #ifndef SQUID_ESICONTEXT_H
33 #define SQUID_ESICONTEXT_H
35 #include "clientStream.h"
37 #include "esi/Element.h"
38 #include "esi/Parser.h"
39 #include "http/StatusCode.h"
42 class ClientHttpRequest
;
46 class ESIContext
: public esiTreeParent
, public ESIParserClient
50 typedef RefCount
<ESIContext
> Pointer
;
55 errorstatus(Http::scNone
),
62 cachedASTInUse(false),
65 memset(&flags
, 0, sizeof(flags
));
77 /* when esi processing completes */
78 void provideData(ESISegment::Pointer
, ESIElement
*source
);
79 void fail (ESIElement
*source
, char const*anError
= NULL
);
84 void setErrorMessage(char const *);
86 void addStackElement (ESIElement::Pointer element
);
87 void addLiteral (const char *s
, int len
);
89 void finishChildren ();
91 clientStreamNode
*thisNode
; /* our stream node */
92 /* the request we are processing. HMM: cbdataReferencing this will result
93 * in a circular reference, so we don't. Note: we are automatically freed
94 * when it is, so thats ok. */
95 ClientHttpRequest
*http
;
102 /* an error has occured, send full body replies
103 * regardless. Note that we don't fail midstream
104 * because we buffer until we can not fail
108 int finishedtemplate
:1; /* we've read the entire template */
109 int clientwantsdata
:1; /* we need to satisfy a read request */
110 int kicked
:1; /* note on reentering the kick routine */
111 int detached
:1; /* our downstream has detached */
114 err_type errorpage
; /* if we error what page to use */
115 Http::StatusCode errorstatus
; /* if we error, what code to return */
116 char *errormessage
; /* error to pass to error page */
117 HttpReply
*rep
; /* buffered until we pass data downstream */
118 ESISegment::Pointer buffered
; /* unprocessed data - for whatever reason */
119 ESISegment::Pointer incoming
;
120 /* processed data we are waiting to send, or for
121 * potential errors to be resolved
123 ESISegment::Pointer outbound
;
124 ESISegment::Pointer outboundtail
; /* our write segment */
125 /* the offset to the next character to send -
126 * non zero if we haven't sent the entire segment
129 size_t outbound_offset
;
130 int64_t readpos
; /* the logical position we are reading from */
131 int64_t pos
; /* the logical position of outbound_offset in the data stream */
137 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
138 int stackdepth
; /* self explanatory */
139 ESIParser::Pointer theParser
;
140 ESIElement::Pointer
top();
141 void init (ESIParserClient
*);
144 void freeResources();
146 int parsing
:1; /* libexpat is not reentrant on the same context */
152 parserState
; /* todo factor this off somewhere else; */
153 ESIVarState
*varState
;
154 ESIElement::Pointer tree
;
157 RefCount
<ESIContext
> cbdataLocker
;
158 bool failed() const {return flags
.error
!= 0;}
164 void freeResources();
165 void fixupOutboundTail();
169 void appendOutboundData(ESISegment::Pointer theData
);
170 esiProcessResult_t
process ();
172 void parseOneBuffer();
173 void updateCachedAST();
174 bool hasCachedAST() const;
176 virtual void start(const char *el
, const char **attr
, size_t attrCount
);
177 virtual void end(const char *el
);
178 virtual void parserDefault (const char *s
, int len
);
179 virtual void parserComment (const char *s
);
182 CBDATA_CLASS2(ESIContext
);
185 #endif /* SQUID_ESICONTEXT_H */